Question
Please do this for me in Linux. The driver.cpp, and circle.h are shown below. Intro: In Linux and Unix system in order to create programs/applications
Please do this for me in Linux. The driver.cpp, and circle.h are shown below.
Intro:
In Linux and Unix system in order to create programs/applications we need to use the
command line equivalent of a compiler and debugger. On Linux systems there is a compiler
that is open source and provided as a package an administrator can install. These are Known
as GNU Compilers, the packages that are included is for c and c++ as well as some older
programing languages such as Fortran and perl. We will be focusing on gcc(c compiler) and
g++(c++ compiler).
Lab:
Objective: To learn how to compile and debug code on Linux platforms using the command
line tools gdb and g++, There will be 4 syntax errors and 3 logical errors in the code.
Deliverables:
Take a screen shot of the program running before each correction, and after each correction,
so i can see the progress.
Task Compiling:
1) Download the two files from blackboard, driver.cpp, and circle.h
2) Create a new directory to store the files in
3) Compile the code
a) Run the command g++ driver.cpp -o executable_name, this will compile the
code both for driver.cpp and the referenced file circle.h
4) Using the error messages that the compiler gives you correct the syntax errors
5) repeat this process until all syntax errors are resolved.
When compiling code, the compiler checks the files for syntax errors and link errors
first, if it finds any errors it displays them on the screen and aborts compiling the code. Other
Compilers such as Visual Studio and Eclipse do something similar; the major difference is in
how they word the errors. Some errors may look similar and some may not.
To find the syntax errors are straightforward every time you compile the code the
compiler will tell you any syntax errors. Logical errors on the other hand a compiler cannot
help you with, in these cases we use a debugger. A debugger is an application that acts as a
wrapper for the application execution, when you use a debugger the program you are
debugging executes as a child process to the debugger and using various system calls
intercepts and gains control after each line of execution of the child process. The
user/developer has control of the flow of the program. A debugger also gets a snapshot of the
application memory of the program that you are debugging, this way the user can track the
values of each variable after each line executes.
Task Debugging:
Debugging applications in Linux using the debugger known gdb
Reference:http://web.eecs.umich.edu/~sugih/pointers/gdbQS.html
1) Compile the code using g++ driver.cpp o executable_name g, this will Compile
the code and create symbols for the debugger to use.
2) Run gdb on your executable
gdb executable_name
3) When in gdb(when you have a prompt that looks like (gdb)) type the command
start
This will execute the code for the executable that you are working on.
4) Type continue to execute the next line of code in your executable.
If you hit an error the debugger quits the execution of the code,
5) Read the error messages and return to the bash shell by typing quit in gdb.
6) Make the corrections to the code and re-compile the code.
7) Repeat this process until all logical errors is corrected.
circle-1.h
#include
circle_1-1.cpp
#include
double users_radius;// value to store users given radius value; Circle * first_circle;// define a pointer to a circle first_circle = new Circle();// allocate memory for the object and call the constructor
cout<<"This Program computes various metrics of a circle"
first_circle->set_rad(users_radius);
cout<<"Area of circle is:"<
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started