Skip to content
Latchkey

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 status

Common causes

How to fix it

Order libraries after objects

  1. Place -lssl -lcrypto after your object files on the link line.
  2. Install libssl-dev and keep -lcrypto present for crypto symbols.
ld
gcc net.o -o app -lssl -lcrypto   # libs after the objects

How 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

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →