問題:如何使用gcc編譯器編譯C++程序?使用gcc編譯C++程序
info.c:
#include<iostream>
using std::cout;
using std::endl;
int main()
{
#ifdef __cplusplus
cout << "C++ compiler in use and version is " << __cplusplus << endl;
#endif
cout <<"Version is " << __STDC_VERSION__ << endl;
cout << "Hi" << __FILE__ << __LINE__ << endl;
}
,當我嘗試編譯info.c
$ gcc info.C
Undefined first referenced
symbol in file
cout /var/tmp/ccPxLN2a.o
endl(ostream &) /var/tmp/ccPxLN2a.o
ostream::operator<<(ostream &(*)(ostream &))/var/tmp/ccPxLN2a.o
ostream::operator<<(int) /var/tmp/ccPxLN2a.o
ostream::operator<<(long) /var/tmp/ccPxLN2a.o
ostream::operator<<(char const *) /var/tmp/ccPxLN2a.o
ld: fatal: Symbol referencing errors. No output written to a.out
collect2: ld returned 1 exit status
是不是gcc編譯器能夠編制C++程序的? 在相關說明中,gcc和g ++有什麼區別。 謝謝,
可能重複[g ++和gcc有什麼區別?](https://stackoverflow.com/questions/172587/what-is-the-difference-between-g-and-gcc) – 2017-12-05 10:54:02