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

How to install gcc on centos7?

coldplay.xixi
Release: 2020-07-28 14:01:22
Original
22389 people have browsed it

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
Copy after login

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

 [root@localhost ~]#gcc --help
Copy after login

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保存退出
Copy after login

2. Enter the command:

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

You can use the following command to view:

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

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

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

4. Enter the command:

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

Enter the command:

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

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

 [root@localhost ~]# vi  helloworld.s
Copy after login

Enter the command:

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

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!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template