//
you're reading...
C, GNU/Linux, Programming, Ubuntu

C Programming on GNU/Linux Using GCC

GCC (acronym for GNU Compiler Collection) is a compiler system produced by the GNU Project supporting various programming languages like C, C++, Objective-C, Fortran, Java, Ada, and Go.GCC is a key component in the collection of programming tools produced by the GNU Project.And the official compiler for the GNU/Linux Operating System .

Now Let us create our first C program on Linux

The things required for creating C programs are

  • A Text Editor – like gedit
  • Compiler – GCC
  • C Standard Library – GNU C Library known as glibc

The Text Editor am using is gedit ..you can use any one of your choice ..

The compiler being used is the standard compiler for the GNU Operating System -GCC .

Its necessary to see if GCC has been installed or not so issue the command

$ gcc

now if u get a message as “GCC : no input filesthis indicates that the GCC is installed and ready to use.

 

 

 

 

The GNU C Library commonly known as glibc is the C standard library released by the GNU Project.

The locate command can be used to confirm that glibc is already installed on the system as follows:

$ locate glibc

if its on the system it will show where its present ..

 

 

 

 

Now lets come to the actual programming part

>> Writing The Program

lets write a small piece of code using some text editor

 

 

 

 

 

 

 

 

 

i have named the file as hello.c

>> Compiling The Program

The program can be compiled using GCC by using the following command

gcc -o hello hello.c

 

 

 

 

The -o option informs the compiler of the desired name for the executable file that it produces.If there are any errors in the program the compiler will show an error message ..

>> Running The Program

Running the program is done in classic Linux style by using the Dot-slash command (./)

./hello

The result will be displayed on the screen …

 

 

 

 

This is a “Hello World”  Tutorial on C Programming on GNU/Linux Using GCC !!

The official GCC page is available here

——————————————————————————————————————————————-

(Information for this post was gathered from linfo and Wiki pages on GNU C Library and GCC .)

Advertisements

About Suhas Dwarakanath

Embedded Engineer interested in Electronics and GNU/Linux

Discussion

3 thoughts on “C Programming on GNU/Linux Using GCC

  1. Good hard work. I like the content. Keep it up.

    Posted by c programming tutorial | February 19, 2011, 9:17 pm
  2. thanks fro the help.

    Posted by Sac | January 7, 2012, 4:12 pm

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: