DEBUGGING STAGE
BUILD W/ DEBUGGING SYMBOLS
root@dev:~$ gcc -Wall -g -c programName.c -o objectFileOnly.o
root@dev:~$ ls
programName.c programName.o
* the -g adds debugging information to the compiled output.
- this enabled devs or sre to use a debugger like gdb to step through the
code line-by-line
* the -c compiles only and doesn't link.
- it creates an object file (programName.o), NOT an executable yet.
32-BIT W/O OPTIMIZATION
#OPTIMIZATION TURNED OFF
root@dev:~$ gcc -g -m32 -O0 sourceFile.c outputFile.out
64-BIT W/O OPTIMIZATION
#OPTIMIZATION TURNED OFF
root@dev:~$ gcc -g -m64 -O0 sourceFile.c -o outputFile.out
DISPLAY COMMON WARNINGS AND ERROS
root@dev:~$ gcc -Wall source.c -o output
* this will display important warnings such as uninitialized variables, bad casts, etc.
- it is a good habit to always use -Wall
- the -Wall flag is actually two sets of options
- -W (warnings)
- all (all warnings)
root@dev:~$ gcc -Wall -Werror source.c -o output
* the -Werror causes gcc to treat all warnings as errors
- this option will result in NO C program successfully building when any warnings
are present
Last updated