XCode 3.2.6和4链接器错误ld:坏codegen,指针diff ...到全局弱符号 [英] XCode 3.2.6 and 4 linker errors ld:bad codegen, pointer diff in ... to global weak symbol

查看:168
本文介绍了XCode 3.2.6和4链接器错误ld:坏codegen,指针diff ...到全局弱符号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有XCode 3.2.6和4这个非常奇怪的错误。
XCode 3.2.5对我的项目是免费的。

I have this very strange errors with XCode 3.2.6 and 4. XCode 3.2.5 is free from them for my project.

符号隐藏by defaults option is set to YES。

Symbol hidden by defaults option is set to YES.

此链接与模板类中的静态成员(指针)相关。
任何想法,编译器/链接器键检查,什么?
谢谢!

This link erros are related to static members (pointers) inside template classes. Any ideas, compiler/linker keys to check, anything ? Thanks!

推荐答案

这与你编译的库中的符号可见性有关。 GCC 4.0开关-fvisibility = hidden选项旨在隐藏DSO /共享对象库的符号以减少链接/加载时间。但是,我已经看到一些博客在编译静态库时以一些特殊的方式在线使用开关。我实际上没有找到这是什么效果或意图。据我所知,静态库需要为你打算从外部使用的函数暴露符号信息。

This has to do with symbol visibility in the libraries you have compiled. The GCC 4.0 switch -fvisibility=hidden option is intended to hide symbols for DSO/shared object libraries to reduce link/load times. However, I have seen some blogs online using the switch in some peculiar manner when compiling static libraries. I haven't actually been able to find out what the effect or intent of this is. To the best of my knowledge, static libraries need symbol information exposed for functions you intend to use from the outside.

我遇到过这个链接器错误与boost ::异常。然而,为了捕获特定类型的异常,GCC需要类型信息,但这是一个运行时问题。因此,即使它正确地编译/链接,如果您打算从库外部捕获异常,在项目中隐藏符号信息不是正确的解决方案。参见Apple的文档:

I experienced this same linker error with boost::exceptions. However, in order to catch exceptions of a particular type, GCC requires type information, but that is a run-time issue. Thus, even if it compiles/links correctly, hiding symbol information in your projects is not the correct solution if you intend to catch an exception from outside the library. See Apple's documentation:


如果您的符号使用运行时类型标识(RTTI)信息,异常或动态转换另一个库,如果希望处理由其他库发起的请求,则您的符号必须可见。例如,如果为C ++标准库中的类型定义一个catch处理程序,并且想要捕获C ++标准库抛出的该类型的异常,那么必须确保您的typeinfo对象是可见的。

If your symbol uses runtime type identification (RTTI) information, exceptions, or dynamic casts for an object that is defined in another library, your symbol must be visible if it expects to handle requests initiated by the other library. For example, if you define a catch handler for a type in the C++ standard library, and you want to catch exceptions of that type thrown by the C++ standard library, you must make sure that your typeinfo object is visible.

资料来源: http://developer.apple.com/library/mac/#documentation/DeveloperTools/Conceptual/CppRuntimeEnv/Articles/SymbolVisibility.html

我实际上需要修改带有这里描述的宏卫士的异常头,使我的项目编译和链接: http://gcc.gnu.org/wiki/Visibility 。这是必要的,即使使用-fvisibility = default,这让我相信这是一些链接器错误。

I actually needed to modify the exception header with the macro guards described here to get my project to compile and link: http://gcc.gnu.org/wiki/Visibility. This was neccessary even with -fvisibility=default, which makes me believe this was some sort of linker bug.

然而,我记录了一个BUBA Boost这里: https://svn.boost.org/trac/boost/ticket/4594#comment: 11

Nevertheless, I logged a bug against Boost here: https://svn.boost.org/trac/boost/ticket/4594#comment:11

您可以在这里找到我的设定: http://lists.boost.org/boost-users/2011/07/69251.php

You can find my configuration here: http://lists.boost.org/boost-users/2011/07/69251.php

这篇关于XCode 3.2.6和4链接器错误ld:坏codegen,指针diff ...到全局弱符号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆