Pages

Wednesday, March 4, 2015

Install GCC Compiler on centos

Install gcc

[root@localhost /]# yum install gcc gcc-c++


check gcc version

[root@localhost /]# gcc --version
gcc (GCC) 4.4.7 20120313 (Red Hat 4.4.7-11)
Copyright (C) 2010 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.


Test gcc C compiler with a sample foo.c program

Create a file called test.c :
#vim test.c

add text like this :

#include<stdio.h>
int main(void){
printf("Hello World!\n");
return 0;
}


To compile test.c into foo executable file, type:
# cc test.c -o test


To execute foo program, type:

# ./test
Hello World!


No comments:

Post a Comment