xcode with boost : linker(Id) Warning about visibility settings
Asked Answered
U

6

35

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

it works fine but I always get hundreds of Apple Mach-O Linker(id) Warnings like:

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.

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?

edited again: After a rebuild the remaining 3 warning are gone as well! So my solution did work!

Undercool answered 30/12, 2011 at 23:33 Comment(0)
U
27

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

Undercool answered 30/12, 2011 at 23:40 Comment(5)
Was yes the problem or the solution? :)Hyatt
set to yes will fix the warningsUndercool
How awkward. For me setting Symbols Hidden by Default to No, removed similar warnings coming from linking against a library using Eigen.Depreciate
No matter which way I set "Symbols Hidden by Default" (YES or NO), the boost compiler warnings still persist. I'm using LLVM compiler in XCode 4.4 on an ARC-enabled iOS project. Still searching for a solution...Boynton
This worked for me, round pi up to 5589 (at the time of writing) :)Dory
H
40

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

 Symbols Hidden by Default
 Inline Methods Hidden
Heartbeat answered 9/8, 2012 at 8:21 Comment(2)
Second time I arrived at this answer and it helped me fix the warning. No idea how the project could've ended up with "Inline methods hidden" being out of sync AGAIN. Xcode updates changed it? Ugh..Scorper
+1 Yep -- unlike the answer suggesting only Symbols Hidden by Default needed to match, I found that Inline Methods Hidden also needed to match.Stidham
U
27

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

Undercool answered 30/12, 2011 at 23:40 Comment(5)
Was yes the problem or the solution? :)Hyatt
set to yes will fix the warningsUndercool
How awkward. For me setting Symbols Hidden by Default to No, removed similar warnings coming from linking against a library using Eigen.Depreciate
No matter which way I set "Symbols Hidden by Default" (YES or NO), the boost compiler warnings still persist. I'm using LLVM compiler in XCode 4.4 on an ARC-enabled iOS project. Still searching for a solution...Boynton
This worked for me, round pi up to 5589 (at the time of writing) :)Dory
S
7

The linker complains about different visibility settings between your project and Boost.

You can also fix that issue by recompiling Boost with the same compatibility settings.

Just add

cxxflags=-fvisibility=hidden

and

cxxflags=-fvisibility-inlines-hidden

to the bjam command line.

Shipman answered 5/1, 2015 at 15:28 Comment(2)
-fvisibility=hidden implies -fvisibility-inlines-hidden. Only the former is necessary.Ferbam
When I install boost I use bootstrap.sh and ./b2 as described in in the doc getting_started/unix-variants.html Where do a place these options?Airdrome
D
2

Setting Symbols Hidden by Default to NO and Inline Methods Hidden to NO worked for me.No need to add any flag to Other C++ flags

Directrix answered 23/8, 2018 at 12:17 Comment(0)
E
1

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

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.

Elaterite answered 15/10, 2013 at 9:12 Comment(0)
H
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
Hazlitt answered 12/1, 2015 at 16:0 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.