/tmp/cceeWwtY.o: In function `main':
helloworld.cpp:(.text+0xa): undefined reference to `std::cout'
helloworld.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/cceeWwtY.o: In function `__static_initialization_and_destruction_0(int, int)':
helloworld.cpp:(.text+0x3d): undefined reference to `std::ios_base::Init::Init()'
helloworld.cpp:(.text+0x4c): undefined reference to `std::ios_base::Init::~Init()'
collect2: error: ld returned 1 exit status
[qiaozan@localhost ~]$ cat helloworld.cpp
这种问题,已确定程序没有问题,但它是从windows上直接上传文件到linux的,所以很可能是换行符号的问题,在linux上换行符号是 “\n”, 而windows上换行符号是 “\r\n”, 所以需要转换,用小工具 dos2unix就可以了
安装:
sudo yum install dos2unix
dos2unix hello.cpp
就可以了