From the course: Debugging C Code

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Compiling code for debugging

Compiling code for debugging - C Tutorial

From the course: Debugging C Code

Start my 1-month free trial

Compiling code for debugging

- [Instructor] Building a debug project involves compiling the code to include debugging information. So, here at the Command Prompt running Ubuntu Linux Bash in Windows 10, you must add a switch to compile the code with debugging information. So, I'll type clang, the name of the compiler and then the -g switch which directs clang as well as the GCC or CC Compilers to include the symbols necessary for the debugger to work. Now, your IDE's compiler internally uses the -g switch to perform this magic and in the source code file name. This file is included with the exercise files and this is the minimum command line format for building source code into a runnable and debuggable program. The program was created using the default name a.out which I'll run right now but this program contains debugging information which the GNU debugger uses to examine the code and to do the same things that an IDE debugger can do. So GDB, the…

Contents