xcode with boost:linker(Id) 关于可见性设置的警告
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/8685045/
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
xcode with boost : linker(Id) Warning about visibility settings
提问by Gob00st
I have been using a boost framework from the link below for my iPhone Xcode project: https://goodliffe.blogspot.com/2010/09/building-boost-framework-for-ios-iphone.html
我一直在为我的 iPhone Xcode 项目使用以下链接中的 boost 框架:https: //goodliffe.blogspot.com/2010/09/building-boost-framework-for-ios-iphone.html
it works fine but I always get hundreds of Apple Mach-O Linker(id) Warnings like:
它工作正常,但我总是收到数百个 Apple Mach-O Linker(id) 警告,例如:
Direct access in __ZN5boost15program_options6detail7cmdline24handle_additional_parserERSt6vectorISsSaISsEE to global weak symbol __ZTVN5boost17bad_function_callE means the weak symbol cannot be overridden at runtime. This was likely caused by different translation units being compiled with different visibility settings.
在 __ZN5boost15program_options6detail7cmdline24handle_additional_parserERSt6vectorISsSaISsEE 中直接访问全局弱符号 __ZTVN5boost17bad_function_callE 意味着不能在运行时覆盖弱符号。这可能是由于使用不同的可见性设置编译不同的翻译单元造成的。
How to get rid of those warnings in code?
如何摆脱代码中的那些警告?
edited: By set Symbols Hidden by Default= YES, I managed to get rid of most of the warnings but there are 3 more left which won't go away, can anyone tell me why?
编辑:通过设置默认隐藏符号= YES,我设法摆脱了大部分警告,但还有3个不会消失,谁能告诉我为什么?
edited again: After a rebuild the remaining 3 warning are gone as well! So my solution did work!
再次编辑:重建后剩余的 3 个警告也消失了!所以我的解决方案确实有效!
采纳答案by Gob00st
Doe just figured how to get rid of hundreds of warning like this : set for an entire target or project with the Symbols Hidden by Defaultbuild setting to YES
Doe 只是想出了如何摆脱数百个这样的警告:为整个目标或项目设置默认隐藏符号构建设置为YES
回答by cyrilchampier
If boost is included by multiple projects, each project must have the same values for
如果 boost 被多个项目包含,则每个项目必须具有相同的值
Symbols Hidden by Default
Inline Methods Hidden
回答by Benoit Blanchon
The linker complains about different visibility settings between your project and Boost.
链接器抱怨您的项目和 Boost 之间的可见性设置不同。
You can also fix that issue by recompiling Boost with the same compatibility settings.
您还可以通过使用相同的兼容性设置重新编译 Boost 来解决该问题。
Just add
只需添加
cxxflags=-fvisibility=hidden
and
和
cxxflags=-fvisibility-inlines-hidden
to the bjam
command line.
到bjam
命令行。
回答by Desert Rose
Setting Symbols Hidden by Defaultto NOand Inline Methods Hiddento NOworked for me.No need to add any flag to Other C++ flags
将默认隐藏的符号设置为NO和将内联方法隐藏设置为NO对我有用。无需向其他 C++ 标志添加任何标志
回答by Samuel Lu
If boost is included by multiple projects, each project must have the same values for
如果 boost 被多个项目包含,则每个项目必须具有相同的值
Symbols Hidden by Default Inline Methods Hidden
默认隐藏的符号内联方法隐藏
nerith said is right, but in Xcode 4.6.3,they is not the above "Symbols Hidden by Default" and "Inline Methods Hidden", and i set the gcc_symbols_private_extern to yes, the warning is disappear.
nerith 说的是对的,但是在 Xcode 4.6.3 中,它们不是上面的“默认隐藏的符号”和“隐藏的内联方法”,我将 gcc_symbols_private_extern 设置为是,警告消失了。
回答by OLL
I also had this problem.
我也有这个问题。
It turns out that I was carelessly doing something like this:
事实证明,我不小心做了这样的事情:
#pragma GCC visibility push(default)
#include <SomeExternalLibrary.h>
void myExampleSymbol();
#pragma GCC visibility pop
Which I solved by changing to:
我通过更改为:
#include <SomeExternalLibrary.h>
#pragma GCC visibility push(default)
void myExampleSymbol();
#pragma GCC visibility pop