OpenSSL link options -lssl and -lcrypto in GCC
24,734
The GCC documentation tells us that -l
is the option to link with a library.
-llibrary
-l library
Search the library named library when linking. (The second alternative with the
library as a separate argument is only for POSIX compliance and is not
recommended.)
So you're telling gcc to link with the libraries "ssl" and "crypto". These libraries are typically installed in /usr/lib
. On Linux they'll be called libssl.so
and libcrypto.so
. On OS X they'll be called libssl.dylib
and libcrypto.dylib
.
Author by
Matt Elson
I am a PhD student in computer science, working in computer vision. My languages of choice are Python and C++ and sometimes I have to work with Matlab.
Updated on July 23, 2022Comments
-
Matt Elson almost 2 years
After adding the link options: -lssl and -lcrypto, my program was correctly compiled. However, I found GCC doesn't include the two options, so where do the options come from?
-
Matt Elson over 12 yearsOn Cygwin they'll be called libssl.a and libcrypto.a
-
Hack06 almost 6 yearsFor static linking use additional parameters like this -static -lcrypto -lz -ldl -static-libgcc (source: stackoverflow.com/a/25811538/4410376)