tommy-huang

在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

分类:

技术点:

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-12-31
  • 2021-11-18
  • 2021-06-25
  • 2021-05-01
  • 2021-05-18
  • 2021-05-28
猜你喜欢
  • 2021-12-27
  • 2021-09-09
  • 2021-04-04
  • 2021-12-03
  • 2021-05-10
相关资源
相似解决方案