gpt4 book ai didi

c++ - libstdc++ 已弃用;移至 libc++ [-Wdeprecated] 但更改会产生编译错误

转载 作者:搜寻专家 更新时间:2023-10-31 02:09:02 25 4
gpt4 key购买 nike

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

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

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

非常感谢。

最佳答案

当您更改为 C++ 标准库的不同实现时,您不能使用已经编译的 .a 文件。

这些库似乎是使用 libstdc++ 编译的,因此公开了仅适用于 libstdc++ 的方法。您需要使用 libc++ 编译的 libohNetCore.alibohNetProxies.a 的拷贝,以便在您切换到 时让它们工作>libc++.

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

如果将最低目标 iOS 更改为 5.0,则可以将 -stdlib=libc++ 添加到编译行:

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

它将使用libc++编译。

如果您将最低目标 iOS 更改为 7.0,那么它将默认使用 libc++ 进行编译,一旦您编译完成,您将拥有 libOhNetCore。 alibc++ 编译。

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

$ 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 的存在表明了这一点。

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

$ 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++ 编译的。

关于c++ - libstdc++ 已弃用;移至 libc++ [-Wdeprecated] 但更改会产生编译错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46927007/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com