I am creating a shared library (we will call it "foo") that uses another library (we will call it "bar"). "bar" uses some functions from OpenSSL.
This is where the problem arises.
"bar" was compiled as a static library, and it turned out that OpenSSL too. So when I link the library ("foo"), I include:
- object files for "foo"
- static library
libbar.a
- OpenSSL static libraries
libcrypto.a
and libssl.a
The build command looks something like this:
g++ -Wl,-soname,libfoo.so -shared file1.o file2.o libbar.a \ libcrypto.a libssl.a -o libfoo.so
However, I get a lot of errors:
ld: ./obj/libbar.a(file1.co): in function initialize_openssl: ssl.c:117: error: undefined reference to 'SSL_library_init'
Running the following command:
nm libssl.a | grep SSL_library_init
It produces the following output:
00000000 T SSL_library_init
Thus, it is obvious that there is nothing wrong with OpenSSL libraries. What could cause something like that? Here are three commands used to build OpenSSL:
export cross=arm-linux-androideabi- ./Configure android --prefix=~/openssl-arm make CC="${cross}gcc" AR="${cross}ar r" RANLIB="${cross}ranlib"
The compilation process is complete without any errors, so I am completely puzzled.
Why am I getting linker errors that reference a bunch of OpenSSL characters that explicitly exist?
Nathan osman
source share