How to fix C++ undefined reference to symbol 'BIO_ctrl_pending@@OPENSSL_3.0.0'
Problem:
When trying to compile your C++ program that is using OpenSSL using a command such as
g++ -o myprogram myprogram.cpp -lssl
you see the following error message:
/usr/bin/ld: /tmp/ccEB0Pid.o: undefined reference to symbol 'BIO_ctrl_pending@@OPENSSL_3.0.0'
/usr/bin/ld: /lib/x86_64-linux-gnu/libcrypto.so.3: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
Solution
You need to link crypto
as well as ssl
:
g++ -o myprogram myprogram.cpp -lcrypto -lssl