简体   繁体   中英

How can I install and use C++ libraries on eclipse?

I want to use libosmium library. Could someone please tell me how do I set up this library after I download it?

All I need to know is the standard way of installing external libraries. I can't really find very clear instructions online.

I'm coding with C++ using the eclipse IDE version 4.18.0.

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.

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

Eclipse-CDT Setting Pictures

Include path settings:

Library & library search path settings

You can also use pkg-config plug in https://marketplace.eclipse.org/content/pkg-config-support-eclipse-cdt

Here is a link to a similar question with answers: Problems importing libraries to my c++ project, how to fix this?

As specified in the other answer, you can usually add a library by looking at the project properties:

  • Properties>>C/C++ Build>>Settings>>GCC C++ Compiler>>Includes

However if you're using a makefile project, the Makefile itself must know about the location of libraries. In this case, in order to avoid an "Unresolved inclusion" warning in the header, you may also want to tell eclipse where the header files are. This way the autocomplete & "Open Declaration" will work. This is found in:

  • Properties>>C++ General>>Preprocessor Includes Paths, Macros etc.

In my case I couldn't figure out how to add a custom configuration and updated the default configuration. I added a path for the Android NDK under the GNU C++ -> CTD User Setting Entries

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM