0

libconfig++が機能する非常に単純な例を取得しようとしています。ただし、コンパイラオプション「-stdlib =libc++」および「-std=c ++ 11」が原因で、次のリンクエラーが発生しています。

環境

ダーウィンiMac.local12.2.0

Darwinカーネルバージョン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)  
4

1 に答える 1

1

エラーメッセージは、このメンバーが機能していることを示しています。

libconfig::Config::lookupValue(const std::string& path, std::string& value) const;

でコンパイルされました-stdlib=libc++(おそらくインラインとしてですが、私は推測しています)。そして、次にこのメンバー関数を呼び出します。

libconfig::Config::lookupValue(char const* path, std::string& value) const

ただし、この後者の関数はでコンパイルされていません-stdlib=libc++

最も可能性の高い修正は、libconfig++をで再コンパイルすることです-stdlib=libc++

于 2013-01-19T17:41:51.487 に答える