小编kio*_*kio的帖子

g ++编译错误

我是Ubuntu的新手.我试着编译一个简单的"Hello World!" Ubuntu 11.04中的c ++代码,带有该代码(在终端中):

gcc -Wall -W -Werror tex.cpp -o tex. 
Run Code Online (Sandbox Code Playgroud)

但编译器返回了很多错误:

/tmp/ccL8c1p8.o: In function `main':
tex.cpp:(.text+0xa): undefined reference to `std::cout'
tex.cpp:(.text+0xf): undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std::operator<< <std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*)'
/tmp/ccL8c1p8.o: In function `__static_initialization_and_destruction_0(int, int)':
tex.cpp:(.text+0x3d): undefined reference to `std::ios_base::Init::Init()'
tex.cpp:(.text+0x42): undefined reference to `std::ios_base::Init::~Init()'
collect2: ld returned 1 exit status
mohrd@mio:~$ gcc -Wall -W -Werror tex.cpp -o tex.
/tmp/ccEke5JP.o: In function `main':
tex.cpp:(.text+0xa): undefined reference to `std::cout'
tex.cpp:(.text+0xf): undefined reference to `std::basic_ostream<char, std::char_traits<char> …
Run Code Online (Sandbox Code Playgroud)

c++ ubuntu g++

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

标签 统计

c++ ×1

g++ ×1

ubuntu ×1