Monthly Archives: October 2012

C under GNU/LINUX

This post is for those novice users who used to write a lot of C programs under Windows environment (using Turbo C, Borland C, Visual C etc.) and wished to move to the GNU/LINUX world. Here is your very first simplest “Hello World” application under Linux.

First, open Terminal. In Ubuntu, press ALT+CTRL+T to open Terminal. Or in general, press ALT+F2 to run application launcher and enter terminal or gnome-terminal. You can also open Terminal using Menu (under Accessories or System Tools).

Edit your C source file using any text-editor. For the sake of simplicity, here we will use gedit to write our hello_world.c source file. Otherwise you can use vim, emacs as console-based text-editor or Kate (under KDE) as GUI-based text-editor.

Image

Image

Do not forget to save the file.

Now compile your hello_world.c source code. Here we have passed  “-o hello_world” parameter to gcc. This is basically our suggested name to the executable. Otherwise, gcc will make the default executable as a.out.Image

Finally, run your executable as

$ ./hello_world

And you will see HELLO_WORLD on the screen.

Image

Advertisements