|
我第一次使用GCC编译C++,出现如下问题。
源码:
[code:1]#include <iostream>
using namespace std;
main (void) {
cout<<"test."<<endl;
}
[/code:1]
使用GCC a.cpp后,出现如下提示:
[code:1]linux:~# gcc a.cpp
/tmp/ccS6U07q.o(.text+0x1b): In function `main':: undefined reference to `std::cout'
/tmp/ccS6U07q.o(.text+0x20): In function `main':: 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/ccS6U07q.o(.text+0x28): In function `main':: undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std::endl<char, std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&)'
/tmp/ccS6U07q.o(.text+0x30): In function `main':: undefined reference to `std::basic_ostream<char, std::char_traits<char> >::operator<<(std::basic_ostream<char, std::char_traits<char> >& (*)(std::basic_ostream<char, std::char_traits<char> >&))'
/tmp/ccS6U07q.o(.text+0x59): In function `__static_initialization_and_destruction_0(int, int)':: undefined reference to `std::ios_base::Init::Init[in-charge]()'
/tmp/ccS6U07q.o(.text+0x8a): In function `__tcf_0':: undefined reference to `std::ios_base::Init::~Init [in-charge]()'
/tmp/ccS6U07q.o(.eh_frame+0x11): undefined reference to `__gxx_personality_v0' collect2: ld returned 1 exit status[/code:1]
不知道在使用GCC编译C++时,要不要外加参数? |
|