【问题标题】:Visibility linker warnings when compiling iOS app that uses Boost编译使用 Boost 的 iOS 应用程序时的可见性链接器警告
【发布时间】:2013-10-04 20:43:33
【问题描述】:

我的 iOS 应用使用了一个依赖于 Boost 的库。在修改 3rdparty 构建系统时,我遇到了诸如此类的链接器警告

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.

还有这个

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.

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

环境:

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

【问题讨论】:

    标签: ios xcode boost linker clang


    【解决方案1】:

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

    在我使用 clang 重建 Boost 后,警告消失了。

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-03-01
      • 2011-03-11
      • 1970-01-01
      • 2012-01-18
      • 1970-01-01
      • 1970-01-01
      • 2019-06-27
      • 1970-01-01
      相关资源
      最近更新 更多