C++ and Linux /Ubuntu Environment. |
Objectives: Unix and Linux are packaged with own compliers.
Ubuntu is a Linux operating system.
|
Step : 1 Go to Dash home and Type terminal to open a
terminal , or notepad to open a note-pad.
Now find the notepad application by typing
“Notepad” in the search box of Dash home pane. Just click on
the shortcut to open this application.
|
Step 2 ; In the
note pad type the following source-code, and save under this
location”~/Desktop/cplus, with cpp extension, as shown below.You can
browse to your destination folder and save this file with cpp
extension as shown below.
Note the file was
saved. Now close this file and open it again from it's default
location.
|
Step: 3 When you
open this file from it's default location, you also notice the path
and location of file
|
Step 5: Now open a terminal window, just by typing
“terminal” in the seraph box of of Dash-Home pane. You may change
the appearance of the terminal window. To change the appearance,
right click on the terminal pane, and select “Prorile>Preferences “,
it will get to this window. Now you would be able change the
appearance of the terminal window
Now get back to the terminal window.If you had used
DOS or command prompt of window, you can use similar command like
“change directory” by writing “cd dir-name” at the prompt on the
terminal windows.
|
Step: 6 Get the
list of contents of directory with “ls” command.
Now let us compile our source-code.
Type this syntax to compile your code : g++ -Wall -W
-Werror test1.cpp -o test1
You just hit enter to execute the command.If your
source-code did not have error, the prompt will return back as shown
below, and you are ready to run the complied code.
The compiled code
was saved at the location shown in the terminal window.
The file named “test1” contains the machine readable
language, created from the file,“test1.cpp”. Before we run this
code, let us take look at the properties of this file.
|
Step 7 : Runtime
views: To execute this application, type “./test1” at the prompt.
To close the
terminal window, type exit.
|
|
|
|