using gcc in linux


No replies
ilukrismx
ilukrismx's picture
Offline
Joined: 2012-03-20
Points: 0

Hi guys and girls!

So i was looking at some post about problems with the gcc and i decided to give some tutorial about how to use the gcc compiler in linux O.S

We log in as root user so we can make changes

First we should make our installation

For ubuntu users in console

sudo apt-get install gcc

For fedora users in console

yum install gcc

This will download and install gcc from the repositories to your computer

I recommend you to do an update after the installation

Ubuntu

sudo apt-get update

Fedora

yum -y update

Type exit in the console to get out of root user so we dont ruin something (hahaha just kidding!!)

To check if we have a gcc installed correctly just type in the console "man gcc" this would give us back a gcc description.

Now we would make our "HeyBuddy.c" program ;)

Type in your favorite text editor ( i personally use Gedit)

#include <stdio.h>

int main()

{

printf("Hey,Buddy! \n");

return 0;

}
save it with the name "HeyBuddy.c"

then we should go were the program was save (In my case we would go to Desktop)

In console we write

cd Desktop "move to Desktop in console"

gcc HeyBuddy.c -o HeyBuddy "As we dont use .exe we only type HeyBuddy"

./HeyBuddy    "This would execute the program"

So i think that's about it, if you have any questions please tell me and i will try to respond as fast as I can

Hope it will help you guys somehow!