ccmdtdm-gcc

Why *.o (object) file is not created while compiling C Program through Command Prompt?


While using code blocks *.o (object) file is created when I hit Build button. But, while using Command Prompt *.o file is not created. What is the reason? I am using TDM-GCC-64.


Solution

  • When you compile a C program using GCC directly from the command line, without using the option -c (compile only), it will create an executable without dumping the intermediate object files.

    Those object files are still created, but they are considered temporary and deleted after the final program is linked.

    When you use an IDE, it usually does separated compilation and linking phases, so the object files are kept around. Which is nice if your program is non-trivial and has many source files, because it speeds up compilation times.

    You can see the full output of the GCC command line with option -v verbose:

    $ gcc -v -o hello hello.c
    ...
    .../cc1 -quiet -v hello.c ... -o /tmp/ccbKBzKx.s
    ...
    ... as -v --64 -o /tmp/ccLm6v3X.o /tmp/ccbKBzKx.s
    ... collect2 ... /tmp/ccLm6v3X.o ... -o hello
    

    NOTES: