I have the same problem too. I was using Eclipse CDT
and trying to build my source code with OpenSSL
headers and I got the same "undefined reference"
problem.
To those who may be also suffering from this type of errors, try these steps:
- Make sure you use the right compiler(for
Ubuntu 18.04
)
right click your project->preference->C/C++ Build->tool chain editor->use CDT internal Builder / Linux gcc
(you can try to run HelloWorld as a test)
C/C++ Build->settings->gcc linker
, see right there is a "+"
, click and type ssl
and crypto
- Rebuild your project, done.
I strongly recommend you to learn gcc compiler command line. If you have compile problem, always use the terminal and command line to see if you can compile it successfully, then compare the succeeded command with the console log in Eclipse, at where you can see the actual gcc command that used to compile your code.
A good resource for gcc command: https://www.rapidtables.com/code/linux/gcc/gcc-l.html