Home > Operation and Maintenance > Linux Operation and Maintenance > Linux installation gcc command

Linux installation gcc command

angryTom
Release: 2019-10-24 17:55:00
Original
41264 people have browsed it

Linux installation gcc command

Linux installation gcc command

Learn about gcc

gcc is the GNU compiler suite ( GNU Compiler Collection), which includes front-ends for C, C, Objective-C, Fortran, Java, Ada, Go language and D language, as well as libraries for these languages ​​(such as libstdc, libgcj, etc.). The original intention of GCC was to be a compiler specially written for the GNU operating system. The GNU system is completely free software. Here, "free" means that it respects the user's freedom.

CentOS installation command


Use yum to install gcc in Centos

yum -y install gcc
Copy after login

Press the Enter key to install gcc Installation, if you want to install g, you need to enter in the command line:

yum -y install gcc-c++
Copy after login

to install g.

Ubuntu installation command


Use apt to install gcc in Ubuntu

sudo apt install build-essential
Copy after login

Verification

gcc --version
Copy after login

Compiling Hello World Example


Compiling a basic C or C program using GCC is very simple. Open a text editor and create the following file:

nano hello.c
Copy after login
#include <stdio.h>
int main(){
    printf ("Hello World!\n");
    return 0;
}
Copy after login

Compile

gcc hello.c -o hello
Copy after login

This will create a binary file named hello in the same directory where you ran the command.

Execute hello program:

./hello
Copy after login

The program will display:

Hello World!
Copy after login

Recommended: [Linux video tutorial]

The above is the detailed content of Linux installation gcc command. 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