Statically linking libsodium.a to a dynamic libraray mylib.so. #1322
derickrk38
started this conversation in
General
Replies: 1 comment 1 reply
-
That looks more like a question on how to use the GNU linker than a question on libsodium :) https://stackoverflow.com/questions/2649735/how-to-link-static-library-into-dynamic-library-in-gcc
|
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hello all
So I am trying to create a standalone dynamic library mylib.so from mylib.cpp for distribution. I am trying to link libsodium.a statically to it. But I get an error. A little new to C++ compiling and building.
commands that i used to build mylib.so:
g++ -std=c++11 -c -fPIC -o mylib.o mylib.cpp
g++ -std=c++11 -shared -o mylib.so mylib.o /usr/local/lib/libsodium.a
Error:
/usr/bin/ld: /usr/local/lib/libsodium.a(libsodium_la-crypto_secretbox_easy.o): relocation R_X86_64_PC32 against symbol `crypto_secretbox_detached' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: final link failed: Bad value
collect2: error: ld returned 1 exit status
based on some suggestion I tried recompiling libsodium with fPIC
./configure CFLAGS=-fPIC
make
but I still get the same error
Please help me out
Beta Was this translation helpful? Give feedback.
All reactions