How do you add libraries to Eclipse CDT? (No such file or directory)

后端 未结 5 2017
梦谈多话
梦谈多话 2021-01-19 12:27

I\'m having some issues adding header libraries.

I right click on my project, and click Properties-> C/C++ General-> Paths and Symbols.

In

5条回答
  •  夕颜
    夕颜 (楼主)
    2021-01-19 13:04

    What to add depends on what you are trying to include. In the case of Boost, there are a number of header-only libraries, and there are some libraries that require linking in static/shared-object libraries (e.g., serialization).

    Header-Only Libraries

    For header-only libraries, you just need to include the base directory of all the header files. With gcc, you add the directory using the -I flag (e.g., -I C:/path/to/boost_52_0). With a managed makefile project in Eclipse, you can accomplish the same using Properties > C/C++ Build > Settings > Tool Settings > GCC C++ Compiler > Directories

    Static/Shared-Object Libraries

    For static/shared-object libraries, you have to specify two options:

    1. -l --> The name of the library, less the 'lib' prefix and the file suffix (e.g., libboost_serialization.dll -> boost_serialization
    2. -L --> The directory to look for the library file in. This is only needed if the library is on a non-standard path.

    As @Chris pointed out, for a managed makefile project, both of these options can be set through Properties > C/C++ Build > Settings > Tool Settings > GCC C++ Linker > Libraries

提交回复
热议问题