Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>The answer heavily depends on the specific compiler (gcc/msvc/clang), the version of that compiler, the architecture of the system, and whether you've asked the compiler to generate debugging information or not. The <a href="https://stackoverflow.com/a/18933431/1430833">answer by @GrahamBorland</a> is correct in that <code>gcc test.c -o test</code> will create a net of only one file, <code>test</code>. However, this is because <code>gcc</code> invokes both the compiler and linker and then deletes both temporary files and intermediate object files (.o) before returning.</p> <p>During compilation, the compiler often generates several temporary files, which it then deletes to clean up. Common ones are:</p> <ol> <li><p>C compilers first run the code through a preprocessor, and often use a temporary file to store the result.</p></li> <li><p>Almost all modern compilers reduce C to an intermediate language that can be better optimized. This is often stored in a temporary file.</p></li> <li><p>Old versions of gcc (possibly new versions, as well) would generate assembly, which was then assembled using <code>gas</code> (the GNU assembler). This step was done using a temporary file (with a .S extension).</p></li> </ol> <p>The result of the compile phase then produces either one or two files:</p> <ol> <li><p>An object file (.o for most Unices, .obj for Windows) that contains compiled but unlinked code. This code cannot be executed; it has external dependencies (the system library, and possibly other libraries) that must be satisfied by a linking phase.</p></li> <li><p>If the user requests debugging information (<code>-g</code> under gcc), then, depending on the architecture and other compilation flags, the compiler may generate a file (or directory) that contains symbolic information used in debugging. The compiler in Mac OS X produces .dSYM directories that contain the debugging information. Under Linux, this is often embedded in the object (.o) file.</p></li> </ol> <p>Finally, Mac, Unix, and Windows have a linking phase, which takes the object files (.o and .obj) and any required libraries (.a, and .so under Linux; .a, .dylib, or a framework under Mac OS X; .lib or .dll under Windows), and produces an executable. This is the phase that generates the executable (.exe under Windows) file.</p> <p>To sum it up, when compiling an executable:</p> <ul> <li><p>The C compiler often creates (and then deletes) a number of temporary files.</p></li> <li><p>The C compiler generates one or more object files.</p></li> <li><p>The linker generates an executable, and may also create (and delete) temporary files.</p></li> <li><p>Some C compilers (e.g., gcc) also operate as front-end drivers for both the compiler and the linker. In this case, the compiler may delete any unneeded temporary files, such as the object files generated by the compilation phase.</p></li> </ul>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload