Linking OpenSSL libraries to a program
Silly "Linux-isms" strike again! Apparently, I need to change my command such that the
-l stuff is at the end like (despite what
man gcc seems to indicate):
gcc -Wall -Wextra -Werror -static -o myApp source1.o source2.o common.o -Lopenssl/openssl-0.9.8k/ -lssl -lcrypto -Iopenssl/openssl-0.9.8k/include
How to link OpenSSL libraries statically in VS2019?
The .lib files that are created in a default build are just stubs to call the dlls.
When building OpenSSL you need to specify that you want to build it for static linking.
Modify the "Configure" line that you used to add "no-shared" onto the end, e.g.
perl Configure --prefix=d:\your\prefix\here VC-WIN32 no-shared
Then you will need to rebuild OpenSSL:
Safely call openSSL functions from inside a shared library
-fvisibility=hidden to hide internal symbols of openSSL from outer modules in the compilation process of openSSL.
-Wl,--exclude-libs,ALL when you compile the SO. For example:
g++ -shared -o mylib.so obj1.o obj2.o -L/path/to/openssl/static-libs -lssl -lcrypto -Wl,--exclude-libs,ALL
I prefer the second method because it also solved the problem of version conflicts on openssl engine (at least in my case).