Ubuntu Step-By-Step Compilation Guide.pdf
Transcript of Ubuntu Step-By-Step Compilation Guide.pdf
UBUNTU GCC COMPILATION
GUIDE
STEP-BY-STEP SCREENSHOTS
1. NORMAL UBUNTU SCREEN
• There are different folders on the Desktop.
• Main concern is the folder “Infero_C_2”.
• This is the folder which contains the C Files, that are to be compiled and executed.
1I. FOLDER “INFERO_C_2”
• The folder contains two C Files, namely helloworld.c and helloworld_2.c
III. helloworld.c PROGRAM FILE
• The program is a basic Hello World Program.
• It will print the statement “Hello World Program 1”.
IV. BASIC TERMINAL WINDOW
• This is how the terminal window looks when it is opened.
• Shortcut :- Ctrl + Alt + T.
V. ls COMMAND
• The ls command is used to show the subfolders and files present in the current folder.
• As in the picture, the “home” folder contains various sub-folders like Documents, Music, Pictures, etc.
VI. cd COMMAND
• The cd Command is used to “change the directory”.
• To go to any subfolder we simply write cd <folder name>; as seen in the picture, how we are going to the Desktop sub-folder.
• cd .. Command is used to go one level up.
• Now by using the cd Command I have further gone into Infero_C_2 Folder, present in Desktop Folder.
• It is in this folder that I have stored my C Files.
VIII. gcc COMMAND
• The gcc Command is used to compile the .c file.
• In the picture, you can see I am using the gcc command to compile the helloworld.c file.
IX. EXECUTING THE .C FILE
• The default output file name is a.out, which is called by the command ./a.out
• This can be changed by using the -o option. (Please refer to slides if you don’t know !!)
• For a sample check out the next slide !!
X. OTHER COMPILATION
METHODS
• This demonstrates the compilation methods -Wall and -o.
• Please refer the slides if you do not know their significance.
XI. CALLING OUTPUT FILE WITH A
DIFFERENT NAME
• This demonstrates how we can call an output file, which has been given a different name by using the -o option.