简体   繁体   English

在Xcode中静态链接id3lib的问题

[英]Issue with statically linking id3lib in Xcode

I'm trying to link id3lib statically to my XCode project. 我正在尝试将id3lib静态链接到我的XCode项目。 I've found some answers in other threads suggesting to add as linker flags the full path to the .a file. 我在其他线程中找到了一些答案,建议将链接器标记添加到.a文件的完整路径。 This works but produces a huge number of errors: 这有效,但会产生大量错误:

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>, 

And so on. 等等。 Again, googling suggests that the issue might be the fact the choice for standard library. 再次,谷歌搜索表明该问题可能是标准库的选择。 Hence I tried to switch the C++ Standard Library field from "Compiler Default" to "libstdc++" (and I'm still getting the huge amount errors) or to "libc++" - and I'm getting way less errors, namely: 因此,我试图将C ++标准库字段从“编译器默认”切换到“libstdc ++”(我仍然收到大量错误)或“libc ++” - 我的错误减少了,即:

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)

I have no idea of how to solve this. 我不知道如何解决这个问题。 If I remove the library full path as linker flag, everything seems to work, but the library is linked dynamically (which doesn't work for me). 如果我删除库完整路径作为链接器标志,一切似乎都有效,但库是动态链接的(这对我不起作用)。 I'm on Mac OS X 10.10; 我在Mac OS X 10.10上; id3lib was installed via homebrew (manual installation tests led to similar results). id3lib是通过自制软件安装的(手动安装测试导致了类似的结果)。

Does anybody have a clue? 有人有线索吗?

Thanks, Daniele 谢谢,Daniele

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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