OPENSSL_LIBS="-llibeay32 -lssleay32"...
Avoid -l
altogether (and -L
, and -Wl,-Bstatic
). The linker sometimes ignores the request for static linking (Apple), and sometimes a script modifies it (I can't tell you how many custom build scripts have bitten me).
Instead, use a fully specified archive just like you would use an object file. In your LDLIBS
add the following so there's no chance for a script to screw things up or the linker to ignore your request:
/usr/local/ssl/lib/libssl.a /usr/local/ssl/lib/libcrypto.a
Obviously, you should change the path of libssl.a
and libcrypto.a
to match your installation.
If you don't have an LDLIBS
, then add it to LDFLAGS
(or "other linker flags" in the IDE).
In Qt, it looks like that would be QMAKE_LFLAGS
or LIBS
. Or you could try this post: How to add "Additional Dependencies" (Linker settings).
The same trick applies to shared objects, too (but linkers favor shared objects, so it usually does not become an issue). That is, you can specify:
/usr/local/ssl/lib/libssl.so /usr/local/ssl/lib/libcrypto.so
The thing to remember when specifying a shared object like above is that you have to specify an rpath
to ensure the runtime linker gets the message. That is, you should add the following to LDFLAGS
or "other linker options":
-Wl,-rpath=/usr/local/ssl/lib
I've been bitten a few when specifying shared objects when using the OpenSSL FIPS Capable Library that resides in /usr/local/ssl/lib
because the runtime linker uses the distribution's OpenSSL in /usr/lib
or /usr/lib64
. The OpenSSL FIPS Capable Library is the one you call FIPS_mode_set
on.
You can also remove (or rename) the shared object from the location, leaving only the static archive. I've had to use this technique in the past when building under Xcode for iPhone. Xcode refused to use the static archive, even with a properly placed -Bstatic
. (Cross-compilers and modified toolchains are some of the worst to use at times). I don't think you should have to modify install directories, so I generally don't use it technique.
To summarize, leave nothing to chance and avoid -l
, -L
, and -Wl,-Bstatic
. Fully specify what you want and use the fully qualified library path name, and use them like object files. Use an rpath
if you are specifying a shared object.
nmake VERBOSE=
output to see what include paths are passed to the toolchain? – Dreadnoughtnmake VERBOSE=1
output. – Dreadnought