2012-04-13 146 views
0

我得到使用gcc这个奇怪的链接错误,想,当我使用Visual Studio的代码工作正常..GCC奇怪的链接错误..适用于Visual Studio 2010的

/tmp/ccfcdCxg.o: In function `global constructors keyed to main': 
codechef_permut2.cpp:(.text+0xa): undefined reference to `std::ios_base::Init::Init()' 
codechef_permut2.cpp:(.text+0x19): undefined reference to `std::ios_base::Init::~Init()' 
/tmp/ccfcdCxg.o: In function `ambig(unsigned long)': 
codechef_permut2.cpp:(.text+0x47): undefined reference to `operator new[](unsigned long)' 
codechef_permut2.cpp:(.text+0x52): undefined reference to `operator new[](unsigned long)' 
/tmp/ccfcdCxg.o:(.eh_frame+0x12): undefined reference to `__gxx_personality_v0' 
collect2: ld returned 1 exit status 

我力张贴任何代码,因为我认为它不是必需的,但如果有人觉得我会发布它。

+1

在这种情况下,我不会发布答案,因为我觉得它不是必需 – jalf 2012-04-13 11:22:52

+2

你用'gcc'或'G ++'链接? – 2012-04-13 11:23:51

+1

你能告诉我们如何调用编译器吗?当您使用gcc而不是g ++编译C++代码时,可能会出现链接错误。 – 2012-04-13 11:23:52

回答

8

我的猜测是,你正在使用gcc而不是g++到链接程序。除非您告诉它,否则gcc将不包含C++库; g++会。

+0

是的,我用gcc ..我想将GCC甚至C++ – questions 2012-04-13 11:26:29

+1

@questions工作:它将编译C++;但如果您使用它来链接您的程序,它将不包含C++库。一般来说,你应该使用'g ++'为C++,'gcc'为C. – 2012-04-13 11:28:35

+0

谢谢..它的工作原理。 – questions 2012-04-13 11:36:31