I have a C++ program which includes lots of libraries, including openssl libcrypto. In fact, the g++ switches are:
-lxml2 -lcrypto -lcurl etc.
The problem is that when I try to run it on a different flavor of Linux, it complains that it cannot load libcrypto.so.8. I did some research and learned about the difference between static and shared libraries, but can't quite figure out what steps to take to compile the libcrypto library in such a way that everything goes into the executable so that my program can be portable. Thanks in advance for any help you can give me.
You need to compile/link with -lcrypto -L dir of libcrypto.a to get a static link. If only .so is available, it will go dynamic.
It is portable in two pieces or if the far end has a compatible .so, hopefully one that is not hacked! It saves space, disk and RAM, increases cache hits as all on one host use same lib at once, and takes little time to dynamically link.
Don't think -Bstatic works quite right in gcc, it's just a compatibility option borrowed from the flags of some esoteric compiler.
You don't need to link in a .a as a library, you can use it just like an object file. (that's what an .a is, essentially -- except it can have more than one .o in it)
gcc myprogram.c /usr/lib/libcrypto.a -o myprogram
It will dynamically link the C runtimes and such dynamically but pull static functions from libcrypto.a as needed, just like it would another .c or .o file.
If you don't have libcrypto.a, you may need to install openssl-dev or whatever your distro hides it under.
Thanks, guys. I think I'll try to treat libcrypto.a as though it were one of my object files. I hope that something works soon, because otherwise, I'll have to find the libcrypto source and include it in my product. My company needs my work to go out the door soon. Again, thanks.
libcrypto.a(fips.o): In function `FIPSCHECK_verify':
(.text+0xafb): undefined reference to `dlopen'
libcrypto.a(fips.o): In function `FIPSCHECK_verify':
(.text+0xb0f): undefined reference to `dlsym'
libcrypto.a(fips.o): In function `FIPSCHECK_verify':
(.text+0xb25): undefined reference to `dladdr'
libcrypto.a(fips.o): In function `FIPSCHECK_verify':
(.text+0xb31): undefined reference to `dlclose'
libcrypto.a(fips.o): In function `FIPSCHECK_verify':
(.text+0xb83): undefined reference to `dlclose'
collect2: ld returned 1 exit status