简体   繁体   中英

Linking with libconfig in c++ on OSX

I have a config file that contains:

#include "libconfig.h++"

I have installed libconfig via homebrew and I am trying to compile my c++ program so that I can use the library but I am having trouble linking to it.

The location of the libconfig .a files is located at /usr/local/Cellar/libconfig/1.4.9/lib/

The documentation says: To link with the library, specify '-lconfig++' as an argument to the linker.

So I have been trying variations on g++ config.cpp -L /usr/local/Cellar/libconfig/1.4.9/lib -lconfig++ -o out.o

But I getting the same error message:

config.cpp:4:10: fatal error: 'libconfig.h++' file not found
#include "libconfig.h++"

Can someone please explain what I am doing wrong?

There is nothing about linker. The compiler says that it can't find the file you include in your cpp. If you have installed libconfig correctly, changing #include "libconfig.h++" to #include <libconfig.h++> will solve the problem. If it does not help, it would mean that there is no "libconfig.h++" in your include path .

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