ld "undefined reference to SSL_*" (OpenSSL link order) in CI
A static-style link only pulls archive members that satisfy earlier references. If -lssl -lcrypto come before the objects that need them, or are missing, OpenSSL symbols stay undefined.
What this error means
Code calling SSL_new, EVP_*, or similar fails to link with "undefined reference", typically because OpenSSL libraries precede the objects or -lcrypto is absent.
ld
/usr/bin/ld: net.o: in function 'connect_tls':
net.c:(.text+0x4a): undefined reference to 'SSL_new'
collect2: error: ld returned 1 exit statusCommon causes
How to fix it
Order libraries after objects
- Place -lssl -lcrypto after your object files on the link line.
- Install libssl-dev and keep -lcrypto present for crypto symbols.
ld
gcc net.o -o app -lssl -lcrypto # libs after the objectsHow to prevent it
- List libraries after the objects that use them and include the full dependency chain (-lssl and -lcrypto) on every TLS link.
Related guides
ld.gold "cannot find -lX" in CIFix ld.gold "error: cannot find -lX" in CI - the gold linker cannot locate a library because it is missing or…
ld "undefined reference to std::__throw_*" (libstdc++ version) in CIFix ld "undefined reference to std::__throw_..." in CI - objects built against a newer libstdc++ are linked t…