Undefined link to Eclipse C ++

I tried more and more time, but I have the same error. When I use an external library, for example, I try to work with openssl and crypto ++, I get the error: "undefined reference to (function)".

I do not know why Eclipse does, that #include has never been. I even tried adding a path from General-Path and Symbols Properties-C / C ++, but nothing.

Can someone help me?

+4
source share
2 answers

You must specify the name of the shared libraries that must be associated with the executable.

Assuming you are using the GNU toolchain, you can do this by following these steps:

  • Right-click the project, then select Properties
  • Go to C/C++ Build Settings
  • Choose GCC C Linker β†’ Libraries
  • In Libraries (-l) add the name of your libraries,
  • If necessary, place the directory where your libraries are located, Library search path (-L) .
+16
source

I have the same problem. I used the Eclipse CDT and tried to compile my source code with OpenSSL headers and I had the same problem with the "undefined reference" .

For those who may also suffer from this type of error, try these steps:

  1. Make sure you use the correct 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 running HelloWorld as a test)
  2. C/C++ Build->settings->gcc linker , see "+" on the right, click and enter ssl and crypto
  3. Rebuild your project, done.

I highly recommend you study the gcc compiler command line. If you have a compilation problem, always use the terminal and command line to see if you can compile it successfully, and then compare the successful command with the console log in Eclipse, where you can see the actual gcc command that was used to compile your code .

Good resource for gcc command: https://www.rapidtables.com/code/linux/gcc/gcc-l.html

0
source

All Articles