试图获得一个非常简单的 libconfig++ 工作示例。但是,由于编译器选项“-stdlib=libc++”和“-std=c++11”,我遇到了以下链接错误。
环境
达尔文 iMac.local 12.2.0
达尔文内核版本 12.2.0
xnu-2050.18.24~1/RELEASE_X86_64 x86_64
资源
Config cfg;
cfg.readFile( "example.cfg" );
string value = "";
const string& key = "application.base";
cfg.lookupValue( key, value );
建造
clang++ -o main main.cpp -lconfig++ -stdlib=libc++ -std=c++11
错误
Undefined symbols for architecture x86_64: "libconfig::Config::lookupValue(char const*, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >&) const", referenced from:
libconfig::Config::lookupValue(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >&) const in main-mFa01w.o ld: symbol(s) not found for architecture x86_64 clang: error: linker command failed with exit code 1 (use -v to see invocation)