PRODUCE OBJECT CODE ONLY: DISABLE LINKER

GCC can compile and link in one step, but will not produce a separate object file. This method is only used if a copy of an object file is needed for backup purposes

root@dev:~$ gcc -Wall -g -c programName.c
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
       - do not enable debbuging symbols on production!
       - only use it prior to production
 * the -c compiles only and doesn't link.
    - it creates an object file (programName.o), NOT an executable yet.
#linking after producing an object file to create an executable
root@dev:~$ gcc -Wall objectFileName.o -o programName
root@dev:~$ ls
 programName  objectFileName.o

Last updated