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.
Asked
Active
Viewed 3,175 times
-4
-
there are a million reasons for that. You have to make it more specific – Jean-François Fabre Jul 14 '18 at 13:34
-
Typically, if you use a command-line compiler to compile one `.c` file straight to an executable (without using the `-c` or `/C` flag), no `.o` file is kept. – Steve Summit Jul 14 '18 at 13:36
1 Answers
3
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:
cc1
is the internal name of the true C compiler, it will dump an assembly file.as
is the assembler that converts assembly into object file.- p
collect2
is the internal name of the linker, that read object files and libraries and creates the final executable.

rodrigo
- 94,151
- 12
- 143
- 190