libstdc++ 已弃用;移至 libc++ [-Wdeprecated] 但更改会产生编译错误 [英] libstdc++ is deprecated; move to libc++ [-Wdeprecated] BUT Changing produces compile error

查看:20
本文介绍了libstdc++ 已弃用;移至 libc++ [-Wdeprecated] 但更改会产生编译错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个实现 OhNet 库的项目.它还为您提供了机会 og 使用该项目是在我加入团队时启动的,他们提供了已编译的库和实现.在重做一些类并清除所有警告后,我的最后一个是不推荐使用 libstdc++;移至 libc++ [-Wdeprecated]".我希望通过更改为建议的选择警告会消失但我得到了一堆编译错误

I am working on a project that implements OhNet Library. It also gives you the opportunity og using The project was started when I joined the team and they gave the compiled library and the implementation. After redoing some classes and Clearing all the warning, the last one I have is "libstdc++ is deprecated; move to libc++ [-Wdeprecated]". I hope that by changing to the suggested choice the warning would go away BUT I get a bunch off compiling errors

Undefined symbols for architecture arm64:
  "std::_List_node_base::unhook()", referenced from:
      OpenHome::Net::CpiSubscriptionManager::Run() in libohNetCore.a(CpiSubscription.o)
      OpenHome::Net::DviSubscriptionManager::Run() in libohNetCore.a(DviSubscription.o)
      OpenHome::Net::CpiDeviceListUpdater::~CpiDeviceListUpdater() in libohNetCore.a(CpiDevice.o)
      OpenHome::Net::CpiDeviceListUpdater::Run() in libohNetCore.a(CpiDevice.o)
      OpenHome::NetworkAdapterChangeNotifier::~NetworkAdapterChangeNotifier() in libohNetCore.a(NetworkAdapterList.o)
      OpenHome::NetworkAdapterChangeNotifier::Run() in libohNetCore.a(NetworkAdapterList.o)
      OpenHome::Net::XmlFetchManager::~XmlFetchManager() in libohNetCore.a(XmlFetcher.o)
      ...
  "std::__throw_length_error(char const*)", referenced from:
      std::vector<OpenHome::Net::Argument*, std::allocator<OpenHome::Net::Argument*> >::_M_insert_aux(__gnu_cxx::__normal_iterator<OpenHome::Net::Argument**, std::vector<OpenHome::Net::Argument*, std::allocator<OpenHome::Net::Argument*> > >, OpenHome::Net::Argument* const&) in libohNetCore.a(CpiService.o)
      std::vector<OpenHome::Net::DvAction, std::allocator<OpenHome::Net::DvAction> >::_M_insert_aux(__gnu_cxx::__normal_iterator<OpenHome::Net::DvAction*, std::vector<OpenHome::Net::DvAction, std::allocator<OpenHome::Net::DvAction> > >, OpenHome::Net::DvAction const&) in libohNetCore.a(DviService.o)
      std::vector<OpenHome::Net::Property*, std::allocator<OpenHome::Net::Property*> >::_M_insert_aux(__gnu_cxx::__normal_iterator<OpenHome::Net::Property**, std::vector<OpenHome::Net::Property*, std::allocator<OpenHome::Net::Property*> > >, OpenHome::Net::Property* const&) in libohNetCore.a(DviService.o)
      std::vector<OpenHome::Net::DviSubscription*, std::allocator<OpenHome::Net::DviSubscription*> >::_M_insert_aux(__gnu_cxx::__normal_iterator<OpenHome::Net::DviSubscription**, std::vector<OpenHome::Net::DviSubscription*, std::allocator<OpenHome::Net::DviSubscription*> > >, OpenHome::Net::DviSubscription* const&) in libohNetCore.a(DviService.o)
      std::vector<OpenHome::Net::Parameter*, std::allocator<OpenHome::Net::Parameter*> >::_M_insert_aux(__gnu_cxx::__normal_iterator<OpenHome::Net::Parameter**, std::vector<OpenHome::Net::Parameter*, std::allocator<OpenHome::Net::Parameter*> > >, OpenHome::Net::Parameter* const&) in libohNetCore.a(Service.o)
      std::vector<OpenHome::MListener*, std::allocator<OpenHome::MListener*> >::_M_insert_aux(__gnu_cxx::__normal_iterator<OpenHome::MListener**, std::vector<OpenHome::MListener*, std::allocator<OpenHome::MListener*> > >, OpenHome::MListener* const&) in libohNetCore.a(Env.o)
      std::vector<OpenHome::ISuspendObserver*, std::allocator<OpenHome::ISuspendObserver*> >::_M_insert_aux(__gnu_cxx::__normal_iterator<OpenHome::ISuspendObserver**, std::vector<OpenHome::ISuspendObserver*, std::allocator<OpenHome::ISuspendObserver*> > >, OpenHome::ISuspendObserver* const&) in libohNetCore.a(Env.o)

我正在使用libohNetCore.a"和libohNetProxies.a"

为什么我会收到此错误?这种变化到底是做什么的?

Why am I getting this errors? What is exactly this change doing?

非常感谢.

推荐答案

当您更改为 C++ 的其他实现时,您不能使用已编译的 .a 文件代码> 标准库.

You can't use the already compiled .a files when you change to a different implementation of the C++ standard libraries.

这些库似乎是用 libstdc++ 编译的,因此公开了仅适用于 libstdc++ 的方法.您需要使用 libc++ 编译的 libohNetCore.alibohNetProxies.a 的副本,以便在切换到 libc++.

These libraries appear to have been compiled with libstdc++, and as such expose methods that will only work with libstdc++. You would need copies of libohNetCore.a and libohNetProxies.a that were compiled with libc++ in order to have them work when you switch to libc++.

我从 github 下载了 OhNet 代码.它被定义为支持 -miphoneos-version-min=2.2,因此它将使用 libstdc++ 进行编译,因为它将被构建为支持 iOS 2.2 和更新版本.

I downloaded the OhNet code from github. It's defined to support -miphoneos-version-min=2.2 so it will compile with libstdc++, as it will be built to support iOS 2.2 and newer.

如果你将最低目标iOS改为5.0,那么你可以在编译行添加-stdlib=libc++:

If you change the minimum targeted iOS to 5.0, then you can add -stdlib=libc++ to the compile line:

compiler = $(toolroot)/clang -stdlib=libc++

它会用 libc++ 编译.

如果您将最低目标 iOS 更改为 7.0,则默认情况下它将使用 libc++ 进行编译,并且一旦编译完成,您将拥有 libOhNetCore.为 libc++ 编译的.

If you change the minimum targeted iOS to 7.0 then it will compile with libc++ by default, and once you've compiled you will have the libOhNetCore.a compiled for libc++.

要检查 .a 是否是为 libstdc++ 或 libc++ 编译的,您需要在其上运行 nm 以查找例如 std::string

To check if a .a is compiled for libstdc++ or libc++, you need to run an nm on it looking for, for example, std::string e.g.

$ nm ./Build/Obj/iOS-arm64/Release/libohNetCore.a | c++filt | grep std::string | head -1
0000000000000084 T OpenHome::Net::CpDeviceCpp::GetAttribute(char const*, std::string&) const

这是用 libstdc++ 编译的 - std::string 的存在表明了这一点.

This is compiled with libstdc++ - the presence of std::string indicates this.

对于 libc++,模式略有不同:

for libc++, the pattern is slightly different:

$ nm ./Build/Obj/iOS-arm64/Release/libohNetCore.a | c++filt | grep string | head -1
0000000000000084 T OpenHome::Net::CpDeviceCpp::GetAttribute(char const*, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >&) const

std::__1 的存在表明它是用 libc++ 编译的.

i.e. the presence of std::__1 indicates that it's compiled with libc++.

这篇关于libstdc++ 已弃用;移至 libc++ [-Wdeprecated] 但更改会产生编译错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆