I have built OpenSSL from source (an intentionally old version; built with ./config && make && make test
) and would prefer to use what I have built without doing make install
to link against my program.
The command that's failing is:
gcc -Wall -Wextra -Werror -static -Lopenssl/openssl-0.9.8k/ -lssl -lcrypto -Iopenssl/openssl-0.9.8k/include -o myApp source1.o source2.o common.o`
And I receive a series of errors similar to:
common.c:(.text+0x1ea): undefined reference to `SSL_write'
This makes me think there's something funky with my OpenSSL. If I omit -Lopenssl/openssl-0.9.8k/
from my command, the error changes to being unable to:
/usr/bin/ld: cannot find -lssl /usr/bin/ld: cannot find -lcrypto
Am I compiling OpenSSL incorrectly? Or how should I best resolve this?
on Fedora 22 32-bit, they are located in /usr/lib, on Ubuntu 15.04 64-bit, the 32-bit OpenSSL libraries are located in /lib/i386-linux-gnu. libcrypto should be in the same directory as libssl.
Silly "Linux-isms" strike again! Apparently, I need to change my command such that the -L
and -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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With