Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to add libs to Eclipse CDT-managed projects

I am using the Eclipse CDT plugin to write simple C programs, and no where in the documentation can I find info on how to:

  • Import C standard libraries such as assert.h, etc.
  • Import non-standard, 3rd party libraries, such as glib, or even perhaps my own local libraries

In Java-land, to add a jar/lib to your project's build/compile path, one solution is to copy the jar into a lib/ directory inside the project, right-click it, and then go to Build Path >> Add to Build Path. I'm wondering what the equivalent is for C programs with CDT?

like image 357
smeeb Avatar asked Oct 14 '25 15:10

smeeb


1 Answers

From http://wiki.eclipse.org/CDT/User/FAQ#How_do_I_add_an_external_library_to_my_C.2B.2B_project.3F

For includes: right click on your project and go to Properties>>C/C++ Build>>Settings>>GCC C++ Compiler >> Includes

you must add the include path for the external library (where the header reside). This information is needed by the Eclipse indexer (code completion etc.) and the compiler

For libraries: right click on your project and go to Properties>>C/C++ Build>>Settings>>GCC C++ Linker >> Libraries you must add the library search path (option -L) and the library you want to link against (option -l). This info is needed for the linker.

like image 100
rost0031 Avatar answered Oct 18 '25 18:10

rost0031



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!