标签: linker-errors

Xcode 4中的"bad codegen,pointer diff"链接器错误

使用Xcode 4重新编译C++ iPhone应用程序我得到了这个讨厌的链接器错误:

ld: bad codegen, pointer diff in __static_initialization_and_destruction_0(int, int)
to global weak symbol vmml::Vector2<float>::ZERO for architecture armv6
Run Code Online (Sandbox Code Playgroud)

谁知道这意味着什么?如何让它消失当然也会很好:)

该应用程序在Xcode 3中无错误地编译和链接.

编辑:解决的办法是设置隐藏的默认符号在项目中的所有目标的所有生成设置.仍然没有更明智的实际问题是什么.

xcode linker linker-errors ios xcode4

13
推荐指数
2
解决办法
9569
查看次数

链接静态库时内联函数的多个定义

我有一个C++程序,我用mingw编译(gcc for Windows).使用包含gcc 4.4.1的mingw的TDM版本.可执行文件链接到两个静态库(.a)文件:它们是用C编写的第三方库; 另一个是由我编写的C++库,它使用C库提供我自己的C++ API.

在我看来,(在我看来,过多)部分C库的功能是在内联函数中实现的.当你使用C库的API时,你无法避免包含内联函数,但当我尝试将它们全部链接在一起时,我会收到链接错误,说明所有内联函数都有多个定义 - 我都有在我的C++包装器库中调用,而我没有调用它,基本上在头文件中内联定义的任何内容都在C库和C++库中为它创建了一个函数.

当包含文件在同一项目中的不同.c或.cpp文件中多次使用时,它不会导致多个定义错误; 问题只是它为每个库生成一个定义.

编译器如何/为什么在两个库中为这些内联函数生成函数和符号?如何强制它停止在我的代码中生成它们?是否有一个工具可以运行以从.a文件中删除重复的函数,或者是一种使链接器忽略多个定义的方法?

(仅供参考,第三方库在其所有标题中都包含#ifdef __cplusplus和extern"C"保护;无论如何,如果这是问题,它不会导致符号的多重定义,它会导致相反的问题,因为符号会不确定或至少不同.)

值得注意的是,如果我链接到第三方C库的DLL,则不会发生链接错误; 然而,我得到奇怪的运行时故障似乎与我的代码有关,它应该从DLL调用自己的函数版本.(好像编译器正在创建我没有要求的本地版本的函数.)

之前已经问过这个问题的类似版本,但是,我没有找到任何这些问题的答案:

这个问题的答案是海报是多个定义变量,我的问题是内联函数的多重定义: 重复多重定义错误在多个cpps中包含相同的标题

这是一个MSVC计划,但我正在使用mingw; 另外,海报在这个问题中的问题是在标题中类主体之外定义C++类构造函数,而我的问题是内联的C函数: 静态Lib多重定义问题

这个傻瓜将他的所有C代码重命名为C++文件,他的C代码不是C++ - 安全:链接时 多个std :: functions的多个定义

这个只是想知道为什么违反一个定义规则不是错误: 具有不同定义的内联函数的不可预测的行为

c c++ linker-errors inline-functions tdm-mingw

12
推荐指数
1
解决办法
2万
查看次数

CUDA链接错误 - Visual Express 2008 - 由于(null)配置文件导致的nvcc致命错误

在过去的两周里,我一直在寻找可能的错误解决方案.我已经成功安装了Cuda 64位编译器(工具)和SDK以及64位版本的Visual Studio Express 2008和带有Framework 3.5的Windows 7 SDK.我正在使用Windows XP 64位.我已经确认VSE能够以64位编译,因为我使用以下网站上的步骤可以使用所有64位选项:(因为Visual Express本身并不包含64位软件包)

http://jenshuebel.wordpress.com/2009/02/12/visual-c-2008-express-edition-and-64-bit-targets/

64位安装的注册表更新可在与上述链接相同的页面上的用户注释中找到.

我已经确认了64位编译能力,因为"x64"可从"工具 - >选项 - > VC++目录"下的下拉菜单中获得,而64位编译不会导致整个项目被"跳过" .我已经包含了64位cuda工具,64 SDK和Visual Express(\ VC\bin\amd64)所需的所有目录.

这是我尝试以64位编译时收到的错误消息:

1>------ Build started: Project: New, Configuration: Release x64 ------
1>Compiling with CUDA Build Rule...
1>"C:\CUDA\bin64\nvcc.exe"    -arch sm_10 -ccbin "C:\Program Files (x86)\Microsoft    Visual Studio 9.0\VC\bin"    -Xcompiler "/EHsc /W3 /nologo /O2 /Zi   /MT  "  -maxrregcount=32  --compile -o "x64\Release\template.cu.obj" "c:\Documents and Settings\All Users\Application Data\NVIDIA Corporation\NVIDIA GPU Computing SDK\C\src\CUDA_Walkthrough_DeviceKernels\template.cu" 
1>nvcc fatal   : Visual Studio configuration file '(null)' could not be …
Run Code Online (Sandbox Code Playgroud)

c++ windows-xp cuda linker-errors visual-c++

12
推荐指数
2
解决办法
2万
查看次数

Q_OBJECT链接器错误!

我在构建应用程序时收到以下链接器错误.

HIMyClass.obj :: error:未解析的外部符号"public:virtual struct QMetaObject const*__thiscall CHIMyClass :: metaObject(void)const"(?metaObject @ CHIMyClass @@ UBEPBUQMetaObject @@ XZ)找不到文件:HIMyClass.obj

HIMyClass.obj :: error:未解析的外部符号"public:virtual void*__thiscall CHIMyClass :: qt_metacast(char const*)"(?qt_metacast @ CHIMyClass @@ UAEPAXPBD @ Z)找不到文件:HIMyClass.obj

HIMyClass.obj :: error:未解析的外部符号"public:virtual int __thiscall CHIMyClass :: qt_metacall(enum QMetaObject :: Call,int,void**)"(?qt_metacall @ CHIMyClass @@ UAEHW4Call @ QMetaObject @@ HPAPAX @ Z)找不到档案:HIMyClass.obj

我的班级声明就像

class CHIMyClass:public QDialog
{
   Q_OBJECT

   ....

};
Run Code Online (Sandbox Code Playgroud)

当我评论Q_OBJECT时,链接器错误消失(显然我无法使用信号和插槽).我使用Qt Creator作为IDE和Qt 4.5.3.当我给Rebuild All时,肯定会调用QMake.我想,它产生的moc_*文件就是问题所在.我使用Windows XP和cl作为编译器.

这个链接器错误背后的原因可能是什么?

c++ qt qt4 linker-errors qobject

12
推荐指数
2
解决办法
2万
查看次数

使用CMake为MSVC9生成的项目文件链接到boost库失败

我正在尝试通过使用CMake创建MSVC9.0项目文件来构建具有boost库的应用程序.

我收到以下错误:

错误3致命错误LNK1104:无法打开文件'libboost_system-vc90-mt-gd-1_44.lib'

这是CMake配置

cmake_minimum_required(VERSION 2.8)
PROJECT( TestProject)
ADD_DEFINITIONS(-D_CRT_SECURE_NO_WARNINGS)
set(BOOST_ROOT "D:/boost_1_44_0")
set(Boost_USE_MULTITHREADED ON)
FIND_PACKAGE( Boost 1.44.0 REQUIRED unit_test_framework system)

INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include)
INCLUDE_DIRECTORIES(${INCLUDE_DIRECTORIES} ${BOOST_ROOT})
LINK_DIRECTORIES(${LINK_DIRECTORIES} "D:/boost_1_44_0/stage/lib")


SET(EXECUTABLE_OUTPUT_PATH ${CMAKE_BINARY_DIR}/bin)
SET(LIBRARY_OUTPUT_PATH ${CMAKE_BINARY_DIR}/bin)
SET(RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
ADD_EXECUTABLE(testapp
main.cpp)

TARGET_LINK_LIBRARIES(testapp
${Boost_SYSTEM_LIBRARY}
)

SET_TARGET_PROPERTIES( testapp PROPERTIES DEBUG_POSTFIX "d" )
Run Code Online (Sandbox Code Playgroud)

我已经使用以下选项为静态和共享(调试和发布)构建了增强功能.

bjam toolset=msvc  variant=debug   link=shared runtime-link=shared threading=multi --build-type=complete stage
bjam toolset=msvc  variant=release link=shared runtime-link=shared threading=multi --build-type=complete stage
bjam toolset=msvc  variant=debug   link=static runtime-link=static threading=multi --build-type=complete stage
bjam toolset=msvc  variant=release link=static runtime-link=static threading=multi --build-type=complete stage
Run Code Online (Sandbox Code Playgroud)

我不确定我在配置中缺少什么.有什么建议?谢谢.

boost cmake linker-errors

12
推荐指数
1
解决办法
9425
查看次数

用g ++链接文件

最近我尝试用g ++编译程序(在Ubuntu上).通常我使用Dev-C++(在Windows上),只要我创建一个项目并将所有必要的文件放在那里,它就可以正常工作.

编译程序时发生的错误是:

$filename.cpp: undefined reference to '[Class]::[Class Member Function]'
Run Code Online (Sandbox Code Playgroud)

使用的文件如下:

带有main函数的源代码(.cpp)文件.

带有函数原型的头文件.

.cpp文件,包含每个函数的定义.

任何帮助将不胜感激.

c++ compiler-errors g++ linker-errors

12
推荐指数
1
解决办法
6万
查看次数

未定义的对新运算符的引用

在我开始编程PSP自制程序应用程序之前,从未见过这个链接器错误.无论如何,我正在制作一个快板游戏,在这种情况下我需要发射射弹或导弹,我需要使用动态和通用阵列.但是我的链接器抱怨对new运算符有一个未定义的引用.下面将是完整的源代码,makefile和错误详细信息.

错误详情:

1>------ Build started: Project: PSP Asteroids, Configuration: Debug Win32 ------
1>  psp-g++ -I. -IC:/pspsdk/psp/sdk/include -O2 -G0 -Wall -I. -IC:/pspsdk/psp/sdk/include -O2 -G0 -Wall -fno-exceptions -fno-rtti -D_PSP_FW_VERSION=150   -c -o main.o main.cpp
1>  psp-gcc -I. -IC:/pspsdk/psp/sdk/include -O2 -G0 -Wall -D_PSP_FW_VERSION=150  -L. -LC:/pspsdk/psp/sdk/lib   main.o -lalleg -lpspgu -lpspirkeyb -lm -lpsppower -lpspaudio -lpsprtc  -lpspdebug -lpspdisplay -lpspge -lpspctrl -lpspsdk -lc -lpspnet -lpspnet_inet -lpspnet_apctl -lpspnet_resolver -lpsputility -lpspuser -lpspkernel -o main.elf
1>  main.o: In function `std::vector<Missile*, std::allocator<Missile*> >::_M_insert_aux(__gnu_cxx::__normal_iterator<Missile**, std::vector<Missile*, std::allocator<Missile*> > >, Missile* const&)':
1>  main.cpp:(.text._ZNSt6vectorIP7MissileSaIS1_EE13_M_insert_auxEN9__gnu_cxx17__normal_iteratorIPS1_S3_EERKS1_[_ZNSt6vectorIP7MissileSaIS1_EE13_M_insert_auxEN9__gnu_cxx17__normal_iteratorIPS1_S3_EERKS1_]+0xb8): undefined …
Run Code Online (Sandbox Code Playgroud)

c++ g++ vector linker-errors

12
推荐指数
1
解决办法
2万
查看次数

当我尝试构建时,添加Reachability类失败

我添加了SystemConfiguration框架.我正在部署3.2及更高版本的目标.我忘了添加一些东西吗?

Undefined symbols for architecture i386:
  "_OBJC_CLASS_$_Reachability", referenced from:
      objc-class-ref in AppDelegate.o
ld: symbol(s) not found for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Run Code Online (Sandbox Code Playgroud)

iphone linker-errors ios

12
推荐指数
1
解决办法
9610
查看次数

无法链接Boost正则表达式

我目前正在尝试通过KIT编译Contraction Hierachies实现,这需要Boost :: Regex.提供的Makefile已经确保(我也手动仔细检查过)g ++随-lboost_regex交换机提供.如果没有安装库,g ++会抱怨.

所以我从我的包源安装了库,并再次尝试编译.这次我得到了很多关于Boost :: Regex的链接器错误.这是一个简短的摘录:

main.o: In function `boost::re_detail::perl_matcher<__gnu_cxx::__normal_iterator<char const*, std::string>, std::allocator<boost::sub_match<__gnu_cxx::__normal_iterator<char const*, std::string> > >, boost::regex_traits<char, boost::cpp_regex_traits<char> > >::unwind_extra_block(bool)':
main.cpp:(.text._ZN5boost9re_detail12perl_matcherIN9__gnu_cxx17__normal_iteratorIPKcSsEESaINS_9sub_matchIS6_EEENS_12regex_traitsIcNS_16cpp_regex_traitsIcEEEEE18unwind_extra_blockEb[_ZN5boost9re_detail12perl_matcherIN9__gnu_cxx17__normal_iteratorIPKcSsEESaINS_9sub_matchIS6_EEENS_12regex_traitsIcNS_16cpp_regex_traitsIcEEEEE18unwind_extra_blockEb]+0x2c): undefined reference to `boost::re_detail::put_mem_block(void*)'
main.o: In function `void boost::re_detail::raise_error<boost::regex_traits_wrapper<boost::regex_traits<char, boost::cpp_regex_traits<char> > > >(boost::regex_traits_wrapper<boost::regex_traits<char, boost::cpp_regex_traits<char> > > const&, boost::regex_constants::error_type)':
main.cpp:(.text._ZN5boost9re_detail11raise_errorINS_20regex_traits_wrapperINS_12regex_traitsIcNS_16cpp_regex_traitsIcEEEEEEEEvRKT_NS_15regex_constants10error_typeE[_ZN5boost9re_detail11raise_errorINS_20regex_traits_wrapperINS_12regex_traitsIcNS_16cpp_regex_traitsIcEEEEEEEEvRKT_NS_15regex_constants10error_typeE]+0x7d): undefined reference to `boost::re_detail::get_default_error_string(boost::regex_constants::error_type)'
main.cpp:(.text._ZN5boost9re_detail11raise_errorINS_20regex_traits_wrapperINS_12regex_traitsIcNS_16cpp_regex_traitsIcEEEEEEEEvRKT_NS_15regex_constants10error_typeE[_ZN5boost9re_detail11raise_errorINS_20regex_traits_wrapperINS_12regex_traitsIcNS_16cpp_regex_traitsIcEEEEEEEEvRKT_NS_15regex_constants10error_typeE]+0xb1): undefined reference to `boost::re_detail::raise_runtime_error(std::runtime_error const&)'
main.cpp:(.text._ZN5boost9re_detail11raise_errorINS_20regex_traits_wrapperINS_12regex_traitsIcNS_16cpp_regex_traitsIcEEEEEEEEvRKT_NS_15regex_constants10error_typeE[_ZN5boost9re_detail11raise_errorINS_20regex_traits_wrapperINS_12regex_traitsIcNS_16cpp_regex_traitsIcEEEEEEEEvRKT_NS_15regex_constants10error_typeE]+0xcb): undefined reference to `boost::re_detail::get_default_error_string(boost::regex_constants::error_type)'
main.o: In function `__gnu_cxx::__normal_iterator<char const*, std::string> boost::re_detail::re_is_set_member<__gnu_cxx::__normal_iterator<char const*, std::string>, char, boost::regex_traits<char, boost::cpp_regex_traits<char> >, unsigned int>(__gnu_cxx::__normal_iterator<char …
Run Code Online (Sandbox Code Playgroud)

linker gcc boost linker-errors boost-regex

12
推荐指数
1
解决办法
2万
查看次数

为什么我得到pthread_mutexattr_settype的未定义引用?

我正在尝试编译和链接Novell LDAP C SDK中的示例文件,但由于pthread库中有3个未解析的符号,链接失败.我在Ubuntu 13.10(Saucy)上使用gcc 4.8.1.我已将pthread库正确地包含在命令行中的最后一个库中,但这些特定符号仍未解析.

$ gcc -Wl,-trace-symbol=pthread_mutexattr_settype -Wl,-trace-symbol=pthread_mutexattr_init   -Wl,-trace-symbol=pthread_mutex_trylock  -o search search.o -L../lib -lldapsdk -lpthread

../lib/libldapsdk.so: reference to pthread_mutexattr_settype<br>
../lib/libldapsdk.so: reference to pthread_mutexattr_init<br>
../lib/libldapsdk.so: reference to pthread_mutex_trylock<br>
/lib/i386-linux-gnu/libpthread.so.0: definition of pthread_mutexattr_settype<br>
/lib/i386-linux-gnu/libpthread.so.0: definition of pthread_mutexattr_init<br>
/lib/i386-linux-gnu/libpthread.so.0: definition of pthread_mutex_trylock<br>
../lib/libldapsdk.so: undefined reference to pthread_mutexattr_settype<br>
../lib/libldapsdk.so: undefined reference to pthread_mutex_trylock<br>
../lib/libldapsdk.so: undefined reference to pthread_mutexattr_init<br>
collect2: error: ld returned 1 exit status

$ readelf --all  /lib/i386-linux-gnu/libpthread.so.0|grep pthread_mutexattr_settype<br>
   114: 00009d90    36 FUNC    GLOBAL DEFAULT   13 pthread_mutexattr_settype@@GLIBC_2.1<br> …
Run Code Online (Sandbox Code Playgroud)

c linux gcc shared-libraries linker-errors

12
推荐指数
2
解决办法
2万
查看次数