Linux installation gcc command

angryTom
angryTomOriginal
2019-10-21 16:29:1341241browse

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

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++

to install g.

Ubuntu installation command


Use apt to install gcc in Ubuntu

sudo apt install build-essential

Verification

gcc --version

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
#include <stdio.h>
int main(){
    printf ("Hello World!\n");
    return 0;
}

Compile

gcc hello.c -o hello

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

Execute hello program:

./hello

The program will display:

Hello World!

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!

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