Question
Using PuTTY Linux Server Task Compiling: 1) Download the two files from blackboard, driver.cpp, and circle.h 2) Create a new directory to store the files
Using PuTTY Linux Server
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
note: -o parameter specifies a new name for the executable, if you do not specify the -o parameter the default name of the executable is a.out
4) Using the error messages that the compiler gives you correct the syntax errors
5) repeat this process until all syntax errors are resolved.
Compiling:
When compiling code, first the compiler checks the source files for syntax errors and link errors, if it finds any errors it displays them on the screen and aborts compiling the code.
Other Compilers such as Visual Studio, GCC/G++, and Eclipse function in a similar manor; one of the notable differences is in how they word the errors. Some errors messages may look similar and some may not.
The process to find the syntax errors is straightforward, every time you compile the code, the compiler will tell you the syntax errors.
Each syntax error will follow the same format
Logical errors on the other hand, a compiler cannot help you with, in these cases we use what is known as a debugger.
Debugging:
A debugger is an application that acts as a wrapper for the application execution, which gives the user/developer the ability to control execution of the program. A debugger gets a map of the application memory of the program, and the program counter, so the user can track the values of each variable after each line executes. The debugger works in conjunction with a compiler, when the source code is compiled, the compiler can generate symbols that the debugger uses in order to understand how to read the code. Without these symbols a debugger can not understand how to read the binary file.
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
note:gdb will tell you exactly which line in the source code produced the error
6) Make the corrections to the code and re-compile the code.
7) Repeat this process until all logical errors are corrected.
PLEASE PROVIDE SCREENSHOTS AS WELL THANK YOU
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