您的位置:首页 > 编程语言 > C语言/C++

How to compile C++ with GCC

2008-01-08 16:09 477 查看
In the midst of TS/Hurricane Gaston, I find this.
If you compile gcc t.cc, it does not find the standard C++ library stdc++.
If you compile gcc -lstdc++ t.cc, it works fine.
If you compile g++ t.cc, it works fine.
But you must always have your program like this:

#include <iostream>
using namespace std;
int main() {
cout << "Hello world" << endl;
return 0;
}

or:

#include <iostream>
int main() {
std::cout << "Hello world" << std::endl;
return 0;
}

不管用不用using namespace都是要-lstdc++指定吧。
当时gcc没找到libstdc++是会报错的
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: