在Xcode中静态链接id3lib的问题

时间:2016-06-29 14:27:45

标签: c++ xcode std id3lib

我试图将id3lib静态链接到我的XCode项目。 我在其他线程中找到了一些答案,建议将链接器标记添加到.a文件的完整路径。这有效但会产生大量错误:

Undefined symbols for architecture x86_64:
  "std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >::copy(char*, unsigned long, unsigned long) const", referenced from:
      dami::io::StringReader::readChars(unsigned char*, unsigned int) in libid3.a(tag_impl.o)
      dami::convert(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, ID3_TextEnc, ID3_TextEnc) in libid3.a(utils.o)
      dami::io::StringReader::readChars(unsigned char*, unsigned int) in libid3.a(tag_parse_lyrics3.o)
  "std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >::compare(char const*) const", referenced from:
      ID3_TagImpl::IsV2Tag(ID3_Reader&) in libid3.a(tag_impl.o)
      dami::mm::parse(ID3_TagImpl&, ID3_Reader&) in libid3.a(tag_parse_musicmatch.o)
      dami::id3::v1::parse(ID3_TagImpl&, ID3_Reader&) in libid3.a(tag_parse_v1.o)
      dami::lyr3::v1::parse(ID3_TagImpl&, ID3_Reader&) in libid3.a(tag_parse_lyrics3.o)
      dami::lyr3::v2::parse(ID3_TagImpl&, ID3_Reader&) in libid3.a(tag_parse_lyrics3.o)
  "std::__1::__vector_base_common<true>::__throw_length_error() const", referenced from:
      void std::__1::vector<ID3_Field*, std::__1::allocator<ID3_Field*> >::__push_back_slow_path<ID3_Field* const>(ID3_Field* const&) in libid3.a(frame_impl.o)
  "std::__1::__basic_string_common<true>::__throw_length_error() const", referenced from:
      std::__1::basic_string<unsigned char, std::__1::char_traits<unsigned char>, std::__1::allocator<unsigned char> >::reserve(unsigned long) in libid3.a(tag.o)
      std::__1::basic_string<unsigned char, std::__1::char_traits<unsigned char>, std::__1::allocator<unsigned char> >::__grow_by_and_replace(unsigned long, unsigned long, unsigned long, unsigned long, unsigned long, unsigned long, unsigned char const*) in libid3.a(tag.o)
      std::__1::basic_string<unsigned char, std::__1::char_traits<unsigned char>, 

等等。再次,谷歌搜索表明该问题可能是标准库的选择。因此,我尝试从&#34;编译器默认&#34;切换C ++标准库字段。 to&#34; libstdc ++&#34; (而且我仍然会收到大量的错误)或者是&#34; libc ++&#34; - 并且我减少了错误,即:

Undefined symbols for architecture x86_64:
  "_compress", referenced from:
      dami::io::CompressedWriter::flush() in libid3.a(io_decorators.o)
  "_iconv", referenced from:
      dami::convert(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, ID3_TextEnc, ID3_TextEnc) in libid3.a(utils.o)
  "_iconv_close", referenced from:
      dami::convert(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, ID3_TextEnc, ID3_TextEnc) in libid3.a(utils.o)
  "_iconv_open", referenced from:
      dami::convert(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, ID3_TextEnc, ID3_TextEnc) in libid3.a(utils.o)
  "_uncompress", referenced from:
      dami::io::CompressedReader::CompressedReader(ID3_Reader&, unsigned int) in libid3.a(io_decorators.o)
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

我不知道如何解决这个问题。如果我删除库完整路径作为链接器标志,一切似乎都有效,但库是动态链接的(这对我不起作用)。我在Mac OS X 10.10上; id3lib是通过自制软件安装的(手动安装测试导致了类似的结果)。

有人有线索吗?

谢谢, 丹尼尔

1 个答案:

答案 0 :(得分:0)

在项目设置中转到 Link Binary With Libraries ,并将项目与系统库libz(_compress,_uncompress)和libiconv(_iconv,_iconv_close,_iconv_open)链接。