【linux 下C语言环境搭建】GCC安装和make安装 |
您所在的位置:网站首页 › c语言编译环境怎么下载 › 【linux 下C语言环境搭建】GCC安装和make安装 |
Linux下使用最广泛的C/C++编译器是GCC,大多数的Linux发行版本都默认安装,不管是开发人员还是初学者,一般都将GCC作为Linux下首选的编译工具。本教程毫不犹豫地使用GCC来编译C程序。 首先检查系统是否安装GCC 以及make gcc -v make -v运行结果如下: (base) [root@laishui-ai sinoma]# gcc -v -bash: gcc: command not found (base) [root@laishui-ai sinoma]# make -v GNU Make 3.82 Built for x86_64-redhat-linux-gnu Copyright (C) 2010 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. (base) [root@laishui-ai sinoma]#没有安装GCC ,那么接下来我们来安装GCC,我们使用最简单的命令yum 安装(联网条件下) yum -y install gcc gcc-c++ kernel-devel如果没有安装make ,也可以使用yum命令来安装(联网条件下) yum -y install make经过一翻安装后,已经安装好了。 下面我们就可以开始C语言开发啦。 创建一个 Cool 文件夹,并进入 创建一个main.c 文件,并编辑 >>cd Cool >>vim main.c (base) [root@laishui-ai Cool]# vim main.c (base) [root@laishui-ai Cool]# gcc main.c -o hello.o (base) [root@laishui-ai Cool]# ll total 16 -rwxr-xr-x. 1 root root 8512 Oct 26 09:44 hello.o -rw-r--r--. 1 root root 82 Oct 26 09:44 main.c (base) [root@laishui-ai Cool]# ./hello.o Hello, World! (base) [root@laishui-ai Cool]#main.c 内容如下: #include int main() { printf("Hello, World!\n"); return 0; }成功编译执行输出hello,world! |
今日新闻 |
推荐新闻 |
CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3 |