ubuntu中编译c++程序的方法:
1.打开终端使用vim编辑c++代码。
vim hello.cpp
输入如下代码:
#include
using namespace std;
int main()
{
cout<<"Hello world!"<return 0;
}
保存修改。
2.使用以下命令进行编译。
gcc hello.cpp -lstdc++ -o hello
//或
g++ hello.cpp -o hello
3.运行可执行文件,在当前目录下输入以下命令查看结果。
./hello
亿速云「云服务器」,即开即用、新一代英特尔至强铂金CPU、三副本存储NVMe SSD云盘,价格低至29元/月。点击查看>>
推荐阅读:ubuntu中怎么编译c++程序