Cannot find libcrypto library error

Add -L /usr/local/ssl/lib/ into the GCC command line, before the -lcrypto. Since you are building against the OpenSSL headers under /usr/local/ssl, you also need to link against the actual library under the same prefix (even though you only appear to have a static one installed there, that may or may not be your intention; you may need to properly reinstall your OpenSSL built from source).

(edit) To fix the dlopen() and friends not being found by the linker, add -ldl into the GCC command line. -ldl tells the linker to also link against libdl.so, which is the shared library containing dlopen(), dlsym(), dlclose() etc.; these functions are used by OpenSSL internally and thus, -ldl is an indirect dependency when using -lcrypto (on Linux). Because you are linking to a static version of libcrypto, you need to explicitly link against all indirect dependencies.

If you are not familiar with linking to the proper libraries, I'd suggest you use OpenSSL as installed from your Operating System package manager; it might save you some trouble.


This might be relevant for people who tried to build their own openssl from source and then use it to compile other programs (in my case Git)

During configuration of openssl, add 'shared' option:

./config shared

This will create the required shared library libcrypto.so. You'll find more in the INSTALL file.

Also, if you run into this error during 'make'

"....can not be used when making a shared object

recompile with -fPIC

./config shared -fPIC