Ubuntu入门——hello world

来源:互联网 发布:一键搭建网站源码 编辑:程序博客网 时间:2024/05/02 00:05

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


原创粉丝点击