Home >Operation and Maintenance >Linux Operation and Maintenance >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!