Home  >  Article  >  Operation and Maintenance  >  How to install gcc on centos7?

How to install gcc on centos7?

coldplay.xixi
coldplay.xixiOriginal
2020-07-28 14:01:2222336browse

How to install gcc on centos7: First enter the system root directory and enter the command [[root@localhost ~]yum -y install gcc gcc-c autoconf make]; then complete the online automatic installation and enter the relevant commands That’s it.

How to install gcc on centos7?

How to install gcc in centos7:

1. Install gcc online (network configuration required)

After installing CentOS7 on the virtual machine VMware Workstation, the system does not have gcc. Enter the system root directory [root@localhost ~] and enter the command:

 [root@localhost ~]yum -y install gcc gcc-c++ autoconf make

, and the online installation will be automatically performed. After completion, enter the command:

 [root@localhost ~]#gcc --help

When the gcc command help appears, the installation is correct.

two. Simple application

We first use the gcc command to write a simple c file.

1. Enter the command:

[root@localhost ~]#vi  helloworld.c   //进入vi编辑器写一个helloworld的c文件。
          #include<stdio.h>
          int main(void)
         { 
         printf(“helloworld !\n”);
          }     //写完按esc,接着按shift+:并输入wq保存退出

2. Enter the command:

 [root@localhost ~]#gcc  helloworld.c //这个命令程序生成默认文件a.out

You can use the following command to view:

 [root@localhost ~]#find / -name  a.out

3. We can use The following command runs this c file:

[root@localhost ~]#gcc -o helloworld helloworld.c //-o 产生可执行的文件名字helloworld

4. Enter the command:

    [root@localhost ~]#gcc -g helloworld.c  -o helloworld  // -g 能被gue调试

Enter the command:

[root@localhost ~]gcc -S helloworld.c  //-S 产生汇编文件后停止编译,后缀名以.s结尾。

We can use the vi editor to view the assembly file:

 [root@localhost ~]# vi  helloworld.s

Enter the command:

[root@localhost ~]#gcc  -E  helloworld.c // -E 选项告诉编译器仅对文件进行预处理并输出到屏幕上

Recommended related tutorials: centos tutorial

The above is the detailed content of How to install gcc on centos7?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn