1. 搭建环境
在terminal下输入:sudo apt-get install gcc gdb vim
或者在terminal下输入:sudo apt-get install build-essential
2. 编写程序
在Documents下创建cppproject文件夹来存放文件
terminal下切换到Documents目录下,然后创建目录: mkdir cppproject
接着切换到cppproject目录下:cd cppproject,在下面新建文件hello.cpp
//hello.cpp
#include <iostream>
int main()
{
std::cout << "hello world" << std::endl;
return 0;
}
3. 编译执行
terminal > cppproject > g++ hello.cpp -o hello.out
terminal > cppproject > ./hello.out
输出: hello world