CentOS 7下搭配简单的C语言开发环境

在CentOS 7下安装gcc,gcc是编译和运行C语言的工具,

安装命令:

yum install gcc

中途如果有询问则输入y

安装成功后,通过以下命令

gcc --version

来查看安装的gcc版本

  具体安装可以查看http://www.centoscn.com/image-text/config/2015/0502/5329.html

进行测试:

  hello.c的代码

#include <stdio.h>
void main(){
    printf("Hello World");   
}

  对代码进行编译和连接,并生成可执行文件

gcc hello.c -o hello.exe

   hello.c为源文件,-o 表示编译并链接,hello.exe为编译结果,可以自定义输出名

    更多关于gcc编译的例子可以查看http://man.linuxde.net/gcc

执行编译后的文件

./hello.exe

Linux下执行命令 ./可执行文件名

  如果出现cannot execute binary file错误,可以参考https://zhidao.baidu.com/question/455297951.html

原文地址:https://www.cnblogs.com/tommy-huang/p/6892881.html