Câu hỏi: Cách biên dịch chương trình C++ bằng trình biên dịch gcc?Soạn thảo chương trình C++ với gcc
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;
}
và khi tôi cố gắng biên dịch 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
Không phải là trình biên dịch gcc có khả năng biên dịch chương trình C++? Trên một lưu ý liên quan, sự khác biệt giữa gcc và g ++ là gì. Cảm ơn,
Bản sao có thể có của [Sự khác nhau giữa g ++ và gcc?] (Https://stackoverflow.com/questions/172587/what-is-the-difference-between-g-and-gcc) –