编译使用Boost的iOS应用程序时,可见性链接器警告

her*_*ube 3 xcode linker boost clang ios

我的iOS应用程序使用的库依赖于Boost.在修改第三方构建系统的同时,我遇到了像这样的链接器警告

ld: warning: direct access in ___cxx_global_var_init to global weak symbol
std::__1::basic_ofstream<char, std::__1::char_traits<char> >::~basic_ofstream()
means the weak symbol cannot be overridden at runtime.
This was likely caused by different translation units being compiled with different visibility settings.
Run Code Online (Sandbox Code Playgroud)

还有这个

ld: warning: direct access in __GLOBAL__I_a to global weak symbol
boost::exception_ptr::~exception_ptr()
means the weak symbol cannot be overridden at runtime.
This was likely caused by different translation units being compiled with different visibility settings.
Run Code Online (Sandbox Code Playgroud)

我看到关于这个警告还有很多其他问题.我按照他们的建议,确保所有版本中的可见性设置都相同(-fvisibility=hidden-fvisibility-inlines-hidden).完全重建后,我仍然收到警告.

环境:

  • Xcode 4.6.0
  • iOS SDK 6.1
  • 使用流行的galbraithjosephs-boostoniphone构建脚本的修改克隆来构建Boost
  • 提升版本1.54.0
  • 建筑用 -std=c++11 -stdlib=libc++

her*_*ube 5

问题是Boost构建脚本用作clang++编译器,但是使用了另一个库和我自己的iOS应用程序clang(其他库和我的应用程序是用于构建构建的Xcode项目clang).

我重建了Boost之后警告消失了clang.

可悲的是,我不知道为什么这会有所帮助.我知道编译时clang++将编译器切换到C++模式,打开/关闭某些设置.但它肯定不能意味着使用在命令行clang++明确指定的覆盖可见性设置?!欢迎提供解释此行为的评论或其他答案.