【问题标题】:Fail linking with C++ library on iOS project与 iOS 项目上的 C++ 库链接失败
【发布时间】:2014-01-30 17:46:17
【问题描述】:

我正在尝试链接 libupnpx,按照说明进行操作,但我似乎无法链接到 C++ 标准库。

Other linker flags 设置为 -lstdc++ -all_load(如您所见 here),但是,它似乎找不到 C++ 函数:here。

知道我可能缺少什么吗?

谢谢。

编辑:正如@Speeder 所问,这里是完整的日志:

Ld /Users/Maxime/Library/Developer/Xcode/DerivedData/OrangeTV-gjzdhpgbpshbbndllvftwfurgmek/Build/Products/Debug-iphonesimulator/OrangeTV.app/OrangeTV normal x86_64
cd /Users/Maxime/Documents/OrangeTV/OrangeTV
setenv IPHONEOS_DEPLOYMENT_TARGET 7.0
setenv PATH "/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin:/Applications/Xcode.app/Contents/Developer/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin"
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -arch x86_64 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator7.0.sdk -L/Users/Maxime/Library/Developer/Xcode/DerivedData/OrangeTV-gjzdhpgbpshbbndllvftwfurgmek/Build/Products/Debug-iphonesimulator -L../Third-Party -L../Third-Party/upnpx -L../Third-Party/upnpx/api -L../Third-Party/upnpx/common -L../Third-Party/upnpx/eventserver -L../Third-Party/upnpx/generator -L../Third-Party/upnpx/port -L../Third-Party/upnpx/ssdp -L../Third-Party/upnpx/upnp -L../Third-Party/upnpx/port/ios -L../Third-Party/upnpx/port/macos -F/Users/Maxime/Library/Developer/Xcode/DerivedData/OrangeTV-gjzdhpgbpshbbndllvftwfurgmek/Build/Products/Debug-iphonesimulator -filelist /Users/Maxime/Library/Developer/Xcode/DerivedData/OrangeTV-gjzdhpgbpshbbndllvftwfurgmek/Build/Intermediates/OrangeTV.build/Debug-iphonesimulator/OrangeTV.build/Objects-normal/x86_64/OrangeTV.LinkFileList -Xlinker -objc_abi_version -Xlinker 2 -lstdc++ -all_load -fobjc-arc -fobjc-link-runtime -Xlinker -no_implicit_dylibs -mios-simulator-version-min=7.0 -lupnpx -framework CoreGraphics -framework UIKit -framework Foundation -Xlinker -dependency_info -Xlinker /Users/Maxime/Library/Developer/Xcode/DerivedData/OrangeTV-gjzdhpgbpshbbndllvftwfurgmek/Build/Intermediates/OrangeTV.build/Debug-iphonesimulator/OrangeTV.build/Objects-normal/x86_64/OrangeTV_dependency_info.dat -o /Users/Maxime/Library/Developer/Xcode/DerivedData/OrangeTV-gjzdhpgbpshbbndllvftwfurgmek/Build/Products/Debug-iphonesimulator/OrangeTV.app/OrangeTV

Undefined symbols for architecture x86_64:
"std::string::find(char const*, unsigned long) const", referenced from:
  SSDPSearchResp::Process(sockaddr*, std::vector<SSDP_HTTP_HEADER*, std::allocator<SSDP_HTTP_HEADER*> >) in libupnpx.a(ssdpsearchresp.o)
  SSDPNotifyAlive::Process(sockaddr*, std::vector<SSDP_HTTP_HEADER*, std::allocator<SSDP_HTTP_HEADER*> >) in libupnpx.a(ssdpnotifyalive.o)
"std::string::c_str() const", referenced from:
  BasicHTTPObserver_wrapper::CanProcessMethod(std::string*) in libupnpx.a(BasicHTTPServer_ObjC.o)
  BasicHTTPObserver_wrapper::Request(char*, unsigned short, std::string*, std::string*, std::string*, std::map<std::string, std::string, std::less<std::string>, std::allocator<std::pair<std::string const, std::string> > >*, char*, int) in libupnpx.a(BasicHTTPServer_ObjC.o)
  -[SSDPDBDevice_ObjC initWithCPPDevice:] in libupnpx.a(SSDPDB_ObjC.o)
  SSDP::Search() in libupnpx.a(ssdp.o)
  SSDPDB::DeleteDevice(unsigned char*, unsigned int) in libupnpx.a(ssdpdb.o)
  SSDPDB::DeleteDevicesByUuid(unsigned char*, unsigned int) in libupnpx.a(ssdpdb.o)
  SSDPDB::GetDevice(unsigned char*, unsigned int) in libupnpx.a(ssdpdb.o)
  ...
"std::string::length() const", referenced from:
  SSDPDB::DeleteDevice(unsigned char*, unsigned int) in libupnpx.a(ssdpdb.o)
  SSDPDB::DeleteDevicesByUuid(unsigned char*, unsigned int) in libupnpx.a(ssdpdb.o)
  SSDPDB::GetDevice(unsigned char*, unsigned int) in libupnpx.a(ssdpdb.o)
  SSDPDB::UpdateCacheControl(unsigned char*, unsigned int, int) in libupnpx.a(ssdpdb.o)
"std::string::compare(std::string const&) const", referenced from:
  bool std::operator<<char, std::char_traits<char>, std::allocator<char> >(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) in libupnpx.a(httpsession.o)
  bool std::operator<<char, std::char_traits<char>, std::allocator<char> >(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) in libupnpx.a(BasicHTTPServer_ObjC.o)
  bool std::operator<<char, std::char_traits<char>, std::allocator<char> >(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) in libupnpx.a(basichttpserver.o)
"std::allocator<char>::allocator()", referenced from:
  SSDP::SSDP() in libupnpx.a(ssdp.o)
  BasicHTTPServer::DataReceived(sockaddr_in*, int, unsigned char*) in libupnpx.a(basichttpserver.o)
"std::allocator<char>::~allocator()", referenced from:
  SSDP::SSDP() in libupnpx.a(ssdp.o)
  BasicHTTPServer::DataReceived(sockaddr_in*, int, unsigned char*) in libupnpx.a(basichttpserver.o)
"std::string::assign(char const*, unsigned long)", referenced from:
  SSDPSearchResp::Process(sockaddr*, std::vector<SSDP_HTTP_HEADER*, std::allocator<SSDP_HTTP_HEADER*> >) in libupnpx.a(ssdpsearchresp.o)
  SSDPDB::InsertDevice(unsigned char*, unsigned int) in libupnpx.a(ssdpdb.o)
  SSDPNotifyAlive::Process(sockaddr*, std::vector<SSDP_HTTP_HEADER*, std::allocator<SSDP_HTTP_HEADER*> >) in libupnpx.a(ssdpnotifyalive.o)
"std::string::replace(unsigned long, unsigned long, char const*)", referenced from:
  SSDPSearchResp::Process(sockaddr*, std::vector<SSDP_HTTP_HEADER*, std::allocator<SSDP_HTTP_HEADER*> >) in libupnpx.a(ssdpsearchresp.o)
  SSDPNotifyAlive::Process(sockaddr*, std::vector<SSDP_HTTP_HEADER*, std::allocator<SSDP_HTTP_HEADER*> >) in libupnpx.a(ssdpnotifyalive.o)
"std::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string(char const*, std::allocator<char> const&)", referenced from:
  SSDP::SSDP() in libupnpx.a(ssdp.o)
  BasicHTTPServer::DataReceived(sockaddr_in*, int, unsigned char*) in libupnpx.a(basichttpserver.o)
"std::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string(std::string const&)", referenced from:
  std::pair<std::string const, std::string>::pair(std::string const&, std::string const&) in libupnpx.a(httpsession.o)
  std::pair<std::string const, std::string>::pair(std::pair<std::string const, std::string> const&) in libupnpx.a(httpsession.o)
  std::pair<std::string const, std::string>::pair(std::string const&, std::string const&) in libupnpx.a(BasicHTTPServer_ObjC.o)
  std::pair<std::string const, std::string>::pair(std::pair<std::string const, std::string> const&) in libupnpx.a(BasicHTTPServer_ObjC.o)
  std::pair<std::string const, HTTPSession*>::pair(std::string const&, HTTPSession* const&) in libupnpx.a(basichttpserver.o)
  std::pair<std::string const, HTTPSession*>::pair(std::pair<std::string const, HTTPSession*> const&) in libupnpx.a(basichttpserver.o)
"std::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string()", referenced from:
  HTTPSession::HTTPSession(char*, unsigned short) in libupnpx.a(httpsession.o)
  HTTPSession::ParseHeader(unsigned char*, int) in libupnpx.a(httpsession.o)
  std::map<std::string, std::string, std::less<std::string>, std::allocator<std::pair<std::string const, std::string> > >::operator[](std::string const&) in libupnpx.a(httpsession.o)
  BasicHTTPObserver_wrapper::Response(int*, std::map<std::string, std::string, std::less<std::string>, std::allocator<std::pair<std::string const, std::string> > >*, char**, int*) in libupnpx.a(BasicHTTPServer_ObjC.o)
  std::map<std::string, std::string, std::less<std::string>, std::allocator<std::pair<std::string const, std::string> > >::operator[](std::string const&) in libupnpx.a(BasicHTTPServer_ObjC.o)
  ___cxx_global_var_init in libupnpx.a(ssdp.o)
  ___cxx_global_var_init9 in libupnpx.a(ssdp.o)
  ...
"std::basic_string<char, std::char_traits<char>, std::allocator<char> >::~basic_string()", referenced from:
  HTTPSession::HTTPSession(char*, unsigned short) in libupnpx.a(httpsession.o)
  HTTPSession::~HTTPSession() in libupnpx.a(httpsession.o)
  HTTPSession::ParseHeader(unsigned char*, int) in libupnpx.a(httpsession.o)
  std::map<std::string, std::string, std::less<std::string>, std::allocator<std::pair<std::string const, std::string> > >::operator[](std::string const&) in libupnpx.a(httpsession.o)
  std::pair<std::string const, std::string>::~pair() in libupnpx.a(httpsession.o)
  std::pair<std::string const, std::string>::pair(std::string const&, std::string const&) in libupnpx.a(httpsession.o)
  std::pair<std::string const, std::string>::pair(std::pair<std::string const, std::string> const&) in libupnpx.a(httpsession.o)
  ...
"std::string::operator=(char const*)", referenced from:
  HTTPSession::ParseHeader(unsigned char*, int) in libupnpx.a(httpsession.o)
  BasicHTTPObserver_wrapper::Response(int*, std::map<std::string, std::string, std::less<std::string>, std::allocator<std::pair<std::string const, std::string> > >*, char**, int*) in libupnpx.a(BasicHTTPServer_ObjC.o)
  SSDP::SetOS(char const*) in libupnpx.a(ssdp.o)
  SSDP::SetProduct(char const*) in libupnpx.a(ssdp.o)
  SSDPDBDevice::SSDPDBDevice() in libupnpx.a(ssdpdbdevice.o)
"std::string::operator=(std::string const&)", referenced from:
  HTTPSession::ParseHeader(unsigned char*, int) in libupnpx.a(httpsession.o)
  BasicHTTPObserver_wrapper::Response(int*, std::map<std::string, std::string, std::less<std::string>, std::allocator<std::pair<std::string const, std::string> > >*, char**, int*) in libupnpx.a(BasicHTTPServer_ObjC.o)
"std::_Rb_tree_decrement(std::_Rb_tree_node_base*)", referenced from:
  std::_Rb_tree_iterator<std::pair<std::string const, std::string> >::operator--() in libupnpx.a(httpsession.o)
  std::_Rb_tree_iterator<std::pair<std::string const, std::string> >::operator--() in libupnpx.a(BasicHTTPServer_ObjC.o)
  std::_Rb_tree_iterator<std::pair<std::string const, HTTPSession*> >::operator--() in libupnpx.a(basichttpserver.o)
"std::_Rb_tree_increment(std::_Rb_tree_node_base const*)", referenced from:
  std::_Rb_tree_const_iterator<std::pair<std::string const, std::string> >::operator++(int) in libupnpx.a(BasicHTTPServer_ObjC.o)
"std::_Rb_tree_increment(std::_Rb_tree_node_base*)", referenced from:
  std::_Rb_tree_iterator<std::pair<std::string const, std::string> >::operator++() in libupnpx.a(httpsession.o)
  std::_Rb_tree_iterator<std::pair<std::string const, std::string> >::operator++() in libupnpx.a(BasicHTTPServer_ObjC.o)
  std::_Rb_tree_iterator<std::pair<std::string const, HTTPSession*> >::operator++(int) in libupnpx.a(basichttpserver.o)
  std::_Rb_tree_iterator<std::pair<std::string const, HTTPSession*> >::operator++() in libupnpx.a(basichttpserver.o)
"std::__throw_length_error(char const*)", referenced from:
  std::vector<SSDPObserver*, std::allocator<SSDPObserver*> >::_M_insert_aux(__gnu_cxx::__normal_iterator<SSDPObserver**, std::vector<SSDPObserver*, std::allocator<SSDPObserver*> > >, SSDPObserver* const&) in libupnpx.a(ssdp.o)
  std::vector<SSDP_HTTP_HEADER*, std::allocator<SSDP_HTTP_HEADER*> >::_M_insert_aux(__gnu_cxx::__normal_iterator<SSDP_HTTP_HEADER**, std::vector<SSDP_HTTP_HEADER*, std::allocator<SSDP_HTTP_HEADER*> > >, SSDP_HTTP_HEADER* const&) in libupnpx.a(ssdpmessage.o)
  std::vector<BasicHTTPObserver*, std::allocator<BasicHTTPObserver*> >::_M_insert_aux(__gnu_cxx::__normal_iterator<BasicHTTPObserver**, std::vector<BasicHTTPObserver*, std::allocator<BasicHTTPObserver*> > >, BasicHTTPObserver* const&) in libupnpx.a(basichttpserver.o)
  std::vector<SocketServerConnection*, std::allocator<SocketServerConnection*> >::_M_insert_aux(__gnu_cxx::__normal_iterator<SocketServerConnection**, std::vector<SocketServerConnection*, std::allocator<SocketServerConnection*> > >, SocketServerConnection* const&) in libupnpx.a(socketserver.o)
  std::vector<SocketServerObserver*, std::allocator<SocketServerObserver*> >::_M_insert_aux(__gnu_cxx::__normal_iterator<SocketServerObserver**, std::vector<SocketServerObserver*, std::allocator<SocketServerObserver*> > >, SocketServerObserver* const&) in libupnpx.a(socketserver.o)
  std::vector<SSDPDBObserver*, std::allocator<SSDPDBObserver*> >::_M_insert_aux(__gnu_cxx::__normal_iterator<SSDPDBObserver**, std::vector<SSDPDBObserver*, std::allocator<SSDPDBObserver*> > >, SSDPDBObserver* const&) in libupnpx.a(ssdpdb.o)
  std::vector<SSDPDBDevice*, std::allocator<SSDPDBDevice*> >::_M_insert_aux(__gnu_cxx::__normal_iterator<SSDPDBDevice**, std::vector<SSDPDBDevice*, std::allocator<SSDPDBDevice*> > >, SSDPDBDevice* const&) in libupnpx.a(ssdpdb.o)
  ...
"std::_Rb_tree_rebalance_for_erase(std::_Rb_tree_node_base*, std::_Rb_tree_node_base&)", referenced from:
  std::_Rb_tree<std::string, std::pair<std::string const, HTTPSession*>, std::_Select1st<std::pair<std::string const, HTTPSession*> >, std::less<std::string>, std::allocator<std::pair<std::string const, HTTPSession*> > >::erase(std::_Rb_tree_iterator<std::pair<std::string const, HTTPSession*> >) in libupnpx.a(basichttpserver.o)
"std::_Rb_tree_insert_and_rebalance(bool, std::_Rb_tree_node_base*, std::_Rb_tree_node_base*, std::_Rb_tree_node_base&)", referenced from:
  std::_Rb_tree<std::string, std::pair<std::string const, std::string>, std::_Select1st<std::pair<std::string const, std::string> >, std::less<std::string>, std::allocator<std::pair<std::string const, std::string> > >::_M_insert(std::_Rb_tree_node_base*, std::_Rb_tree_node_base*, std::pair<std::string const, std::string> const&) in libupnpx.a(httpsession.o)
  std::_Rb_tree<std::string, std::pair<std::string const, std::string>, std::_Select1st<std::pair<std::string const, std::string> >, std::less<std::string>, std::allocator<std::pair<std::string const, std::string> > >::_M_insert(std::_Rb_tree_node_base*, std::_Rb_tree_node_base*, std::pair<std::string const, std::string> const&) in libupnpx.a(BasicHTTPServer_ObjC.o)
  std::_Rb_tree<std::string, std::pair<std::string const, HTTPSession*>, std::_Select1st<std::pair<std::string const, HTTPSession*> >, std::less<std::string>, std::allocator<std::pair<std::string const, HTTPSession*> > >::_M_insert(std::_Rb_tree_node_base*, std::_Rb_tree_node_base*, std::pair<std::string const, HTTPSession*> const&) in libupnpx.a(basichttpserver.o)
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

【问题讨论】:

  • 请发布确切的错误:)
  • 完成!感谢您的帮助。
  • 您是否尝试过-lc++ (LLVM) 而不是-lstdc++ (GCC)?

标签: c++ ios linker static-libraries


【解决方案1】:

我知道这不是一个真正的答案,但我最终使用 Cocoapods 来导入库。 不敢相信我以前没有检查过它是否可用!

【讨论】:

    猜你喜欢
    • 2023-01-07
    • 1970-01-01
    • 2017-05-26
    • 2014-03-24
    • 2021-06-07
    • 1970-01-01
    • 2017-10-06
    • 1970-01-01
    • 2012-12-24
    相关资源
    最近更新 更多