“bad codegen, pointer diff” linker error with Xcode 4

前端 未结 5 1496
臣服心动
臣服心动 2020-12-09 11:04

Recompiling a C++ iPhone app with Xcode 4 I get this nasty linker error:

ld: bad codegen, pointer diff in __static_initialization_and_destruction_0(int, int)         


        
5条回答
  •  北荒
    北荒 (楼主)
    2020-12-09 12:08

    I had the same problem and also ended up adjusting the visibility settings. However, I was nervous just fiddling with symbol visibility and not understanding the problem, so I did a little more investigation.

    If, like me, you're using Pete Goodliffe's script/package to build boost as a framework, the script sets default visibility to hidden (== yes). The visibility options change how symbols are marked by the compiler (default, hidden, internal). That information is used by the linker when making shared object elfs (shared libraries). It shouldn't apply here, so I suspect that this is a linker bug. Inside the boost library you have a weak symbol marked as hidden, and then in your project/another library, the same symbol marked as default. The linker is confused?

    As for XCode 3 vs. 4, perhaps the default in 3 was to hide symbols?

    In any case, changing default visibility to hidden should really have no effect with only static libs involved, so I feel a lot safer taking this route.

    I've posted a few more details in a blog entry for those interested.

提交回复
热议问题