Linux编译C语言文件
环境: CentOS 7.6
用到的文件:qt-opensource-linux-x64-5.8.0.run (请提前准备,暂未测试其他版本)
一、检查编译环境
1. 查看gcc是否安装,不存在则安装
[root@localhost vmware-tools-distrib]# gcc -v
bash: gcc: 未找到命令...
[root@localhost vmware-tools-distrib]# yum -y install gcc gcc-c++

2. 查看是否安装qt-opensource-linux
查看系统未安装qt-opensource-linux,这里在root家目录下创建了一个demo目录做为测试目录,将文件:qt-opensource-linux-x64-5.8.0.run 文件上传到此目录下,给予run文件可执行权限并安装
[root@localhost ~]# qt-opensource-linux bash: qt-opensource-linux: 未找到命令... [root@localhost ~]# mkdir demo [root@localhost ~]# cd demo [root@localhost demo]# pwd /root/demo[root@localhost demo]# ll [root@localhost demo]# chmod +x qt-opensource-linux-x64-5.8.0.run [root@localhost demo]# ./qt-opensource-linux-x64-5.8.0.run

点击Next

可以留空,点击skip

点击Next

这里目录选择的是默认目录,点击Next

默认系统选择,点击Next

勾选同意并点击Next

点击Install

开始安装

点击Finish 完成

二、测试编译文件
在当前目录下创建一个hello.c的测试文件
[root@localhost demo]# vi ./hello.c 注:文件中写入以下数据 #include<stdio.h> int main(){ printf("Hello World!\n"); return 0; } [root@localhost demo]# gcc ./hello.c [root@localhost demo]# ./a.out Hello World!


参考:
Linux编写一个C程序HelloWorld
https://www.cnblogs.com/aeolian/p/9156612.html
(完)

浙公网安备 33010602011771号