我的代碼是在gcc中編譯cpp程序時出現問題
#include<iostream>
using namespace std;
int main()
{
cout <<"hi";
return 0;
}
我用以下代碼編譯:
gcc d.cpp -o d
錯誤如下
Undefined first referenced
symbol in file
std::basic_string<char, std::char_traits<char>, std::allocator<char> >::operator [](unsigned int) const/var/tmp//ccyDVhhA.o
std::cout /var/tmp//ccyDVhhA.o
std::ios_base::Init::~Init() /var/tmp//ccyDVhhA.o
std::ios_base::Init::Init() /var/tmp//ccyDVhhA.o
__gxx_personality_v0 /var/tmp//ccyDVhhA.o
std::basic_ostream<char, std::char_traits<char> >& std::operator<< <std::char_tr aits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*)/va r/tmp//ccyDVhhA.o
std::basic_string<char, std::char_traits<char>, std::allocator<char> >::size() c onst/var/tmp//ccyDVhhA.o
ld: fatal: Symbol referencing errors. No output written to d
collect2: ld returned 1 exit status
上面的代碼有什麼錯誤?
我不能有多少次我看到,當我移動類似的錯誤c到C++ – hhafez 2011-04-08 05:59:27
檢查:http://stackoverflow.com/questions/172587/what-is-the-difference-between-g-and-gcc/173007#173007 – 2011-04-08 06:30:14