现在的位置: 首页 > 综合 > 正文

gcc编译C++文件的错误

2013年10月10日 ⁄ 综合 ⁄ 共 551字 ⁄ 字号 评论关闭

在linux下编译c程序使用gcc,然而编译c++程序却需要使用g++,使用gcc编译c++程序会产生错误:undefined reference to `std::ios_base::Init::Init()。使用gcc -lstdc++编译选项就好。或者改用g++。

 

[root@localhost GameDeal]# gcc -o main main.cpp -ldl
/tmp/ccG8cHL0.o: In function `__static_initialization_and_destruction_0(int, int)':
main.cpp:(.text+0x23): undefined reference to `std::ios_base::Init::Init()'
/tmp/ccG8cHL0.o: In function `__tcf_0':
main.cpp:(.text+0x6c): undefined reference to `std::ios_base::Init::~Init()'
/tmp/ccG8cHL0.o:(.eh_frame+0x11): undefined reference to `__gxx_personality_v0'
collect2: ld 返回 1
[root@localhost GameDeal]#

抱歉!评论已关闭.