Linux环境下如何编译C++程序

版权声明:实不相瞒,我也想成为大佬 https://blog.csdn.net/CV_Jason/article/details/83004082

前言

前段时间面试C++开发,总是被问其Linux编程.
虽然申请的不是服务器开发岗,但是都毫无例外的问我Linux,看来真的挺重要的.
虽然找工作已经告一段落了,但是学习不应该停下脚步。
趁着现在时间比较自由,恶补一波Linux吧。
从第一个小程序开始。

Hello,Linux!

打开终端,输入指令

[jason@localhost ~]$ vim hello.cpp

会进入一个vim编辑器,然后点击键盘上的insert健开始进入编辑模式,如书代码如下:

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

在这里插入图片描述

点击Esc 键退出编辑模式,然后输入冒号和wq ,退出vim编辑器。

输入指令

[jason@localhost ~]$ g++ hello.cpp -o hello
[jason@localhost ~]$ ./hello

得到如下
在这里插入图片描述

至此,第一个Linux C++程序完成,打开一个新世界大门。

猜你喜欢

转载自blog.csdn.net/CV_Jason/article/details/83004082
今日推荐