CentOS 环境下C/C++程序的开发
来源:互联网 发布:知乎创始人周源 编辑:程序博客网 时间:2024/06/05 14:16
CentOS 环境下C++程序的开发(root权限下执行)
====================================================
第一步:检查是否安装gcc和g++
分别执行命令:
[root@localhost~]# gcc -v
[root@localhost~]# g++ -v
版本一致,表明安装正确。
如果没有安装的话:
执行命令:
[root@localhost~]yum install gcc-c++
第二步:编译执行程序。
写好一个 hello.c 程序
//hello.c
#include <stdio.h>
int main()
{
printf("Hello C\n");
return 0;
}
编译命令:
[root@localhost~]gcc -o hello hello.cpp
执行命令:
[root@localhost~]./hello
C++程序的编译过程
//hello.cpp
#include <iostream>
using namespace std;
int main()
{
cout<<"Hello C++"<<endl;
return 0;
}
编译命令:
[root@localhost~]g++ -o myhello hello.cpp
执行命令:
[root@localhost~]./myhello
====================================================
第一步:检查是否安装gcc和g++
分别执行命令:
[root@localhost~]# gcc -v
出现类似以下的提示:
...
gcc version 4.47 20120313 (Red Hat 4.47-3) (GCC)[root@localhost~]# g++ -v
出现类似以下的提示:
...
gcc version 4.47 20120313 (Red Hat 4.47-3) (GCC)版本一致,表明安装正确。
如果没有安装的话:
执行命令:
[root@localhost~]yum install gcc-c++
第二步:编译执行程序。
写好一个 hello.c 程序
//hello.c
#include <stdio.h>
int main()
{
printf("Hello C\n");
return 0;
}
编译命令:
[root@localhost~]gcc -o hello hello.cpp
执行命令:
[root@localhost~]./hello
C++程序的编译过程
//hello.cpp
#include <iostream>
using namespace std;
int main()
{
cout<<"Hello C++"<<endl;
return 0;
}
编译命令:
[root@localhost~]g++ -o myhello hello.cpp
执行命令:
[root@localhost~]./myhello
- CentOS 环境下C/C++程序的开发
- centos下打造VIM的C/C++开发环境
- CentOS下备置C/C++开发环境
- Linux下C语言程序开发环境
- Linux下C语言程序开发环境
- Linux下C程序开发环境笔记
- Linux下C程序开发环境--刘晓涛
- Linux环境下C程序开发
- CentOS下使用VIM打造C/C++开发环境
- CentOS下使用VIM打造C/C++开发环境
- CentOS下使用VIM打造C/C++开发环境
- CentOS下使用VIM打造C/C++开发环境
- CentOS下使用VIM打造C/C++开发环境
- 使用eclipse开发mysql使用C API 在centos下(真正可用 centos6的环境)
- Linux 下 C 开发环境的搭建
- Linux下c开发环境的搭建
- Win7下的C语言开发环境
- Ubuntu下安装C/C++开发环境,Gnome桌面程序开发环境,Java开发环境
- JavaBean 关于属性命名的特殊规范
- android 启动模式之分析
- delphi10进制转换成16进制
- 编程这件小事儿之C语言篇:C语言自学必备
- 计算单词的个数
- CentOS 环境下C/C++程序的开发
- Activity编辑框光标和键盘同时消失
- 【2】OMAP335X-内核BSP之资源注册那些事.
- cocos2d-x暂停和恢复游戏
- DBCS字符集
- Matlab与C/C++混合编程调用OpenCV
- C++标准库中的数学函数
- 细说PHP:人人都能玩转PHP和MySQL Web开发
- 一种可分级防丢包的视频压缩想法