xcode with boost:链接器(Id)关于可见性设置的警告

时间:2022-09-09 07:35:39

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项目: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个警告也消失了!所以我的解决方案确实有效

5 个解决方案

#1


34  

If boost is included by multiple projects, each project must have the same values for

如果多个项目包含boost,则每个项目必须具有相同的值

 Symbols Hidden by Default
 Inline Methods Hidden

#2


24  

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 Default build setting to YES

Doe只是想出了如何摆脱这样的数百个警告:为整个目标或项目设置为“默认隐藏符号”构建设置为YES

#3


3  

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命令行。

#4


0  

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设置为yes,警告消失了。

#5


0  

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

#1


34  

If boost is included by multiple projects, each project must have the same values for

如果多个项目包含boost,则每个项目必须具有相同的值

 Symbols Hidden by Default
 Inline Methods Hidden

#2


24  

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 Default build setting to YES

Doe只是想出了如何摆脱这样的数百个警告:为整个目标或项目设置为“默认隐藏符号”构建设置为YES

#3


3  

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命令行。

#4


0  

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设置为yes,警告消失了。

#5


0  

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