Visibility linker warnings when compiling iOS app that uses Boost

我的梦境 提交于 2020-01-02 07:02:52

问题


My iOS app uses a library which in turn depends on Boost. While revamping the 3rdparty build system, I encountered linker warnings such as this

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.

and this

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.

I saw that there are quite a few other questions on SO regarding this warning. I followed their advice and made sure that the visibility settings in all builds are the same (-fvisibility=hidden and -fvisibility-inlines-hidden). After a full rebuild I still got the warnings.

Environment:

  • Xcode 4.6.0
  • iOS SDK 6.1
  • Building Boost using a modified clone of the popular galbraithjosephs-boostoniphone build script
  • Boost version 1.54.0
  • Building with -std=c++11 -stdlib=libc++

回答1:


The problem was that the Boost build script used clang++ as the compiler, but the other library and my own iOS app used clang (the other library and my app are Xcode projects where builds are made with clang).

The warnings disappeared after I rebuilt Boost with clang.

The sad thing is that I don't know exactly why this helped. I am aware that compiling with clang++ switches the compiler into C++ mode, turning on/off certain settings. But it certainly can't mean that using clang++ overrides visibility settings that are explicitly specified on the command line?! Comments or additional answers explaining the behaviour are welcome.



来源:https://stackoverflow.com/questions/19190458/visibility-linker-warnings-when-compiling-ios-app-that-uses-boost

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!