How to add libs to Eclipse CDT-managed projects

2019-07-21 12:12发布

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?

1条回答
Rolldiameter
2楼-- · 2019-07-21 12:26

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.

查看更多
登录 后发表回答