GCC 奇怪的链接器错误.适用于Visual Studio 2010



我在使用 gcc 时遇到了这个奇怪的链接器错误,认为当我使用 Visual Studio 时代码工作正常。

/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

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

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

最新更新