xcode libstdc++ 已弃用;移至 libc++ [-Wdeprecated] 但更改会产生编译错误
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/46927007/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
libstdc++ is deprecated; move to libc++ [-Wdeprecated] BUT Changing produces compile error
提问by Reimond Hill
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
我正在开发一个实现 OhNet 库的项目。它还为您提供了机会 og 使用该项目是在我加入团队时启动的,他们提供了已编译的库和实现。在重做一些类并清除所有警告后,我的最后一个是“不推荐使用 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)
I am using "libohNetCore.a" and "libohNetProxies.a"
我正在使用“ libohNetCore.a”和“ libohNetProxies.a”
Why am I getting this errors? What is exactly this change doing?
为什么我会收到此错误?这种变化到底在做什么?
Thank you very much.
非常感谢。
采纳答案by Petesh
You can't use the already compiled .a
files when you change to a different implementation of the C++
standard libraries.
.a
当您更改为C++
标准库的不同实现时,您不能使用已编译的文件。
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++
.
这些库似乎是用 编译的libstdc++
,因此公开仅适用于libstdc++
. 你需要的副本libohNetCore.a
,并libohNetProxies.a
认为用汇编libc++
,以便让他们的工作,当你切换到libc++
。
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.
我OhNet
从 github下载了代码。它被定义为支持,-miphoneos-version-min=2.2
因此它将使用 编译libstdc++
,因为它将被构建为支持 iOS 2.2 和更新版本。
If you change the minimum targeted iOS to 5.0
, then you can add -stdlib=libc++
to the compile line:
如果将最小目标 iOS 更改为5.0
,则可以添加-stdlib=libc++
到编译行:
compiler = $(toolroot)/clang -stdlib=libc++
and it will compile with libc++
.
它将与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++
.
如果您将最小目标 iOS 更改为默认情况下7.0
它将编译libc++
,并且一旦您编译,您将libOhNetCore.a
编译为libc++
.
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.
要检查 a.a
是否为 libstdc++ 或 libc++ 编译,您需要在其上运行 nm 以查找例如 std::string eg
$ 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
This is compiled with libstdc++
- the presence of std::string
indicates this.
这是编译的libstdc++
- 的存在std::string
表明这一点。
for libc++, the pattern is slightly different:
对于 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
i.e. the presence of std::__1
indicates that it's compiled with libc++
.
即存在std::__1
表明它是用libc++
.