Mail Archives: djgpp/1997/11/07/10:32:31
On 7 Nov 1997 08:57:12 GMT in comp.os.msdos.djgpp
steven AT freenet DOT edmonton DOT ab DOT ca wrote:
: What's the difference between linking and compiling? I know what compiling
: is... but linking is uncharted territory for myself.
Compilation is turning your C source code into object files, which
contain machine code, data, symbol names, etc. They're not
executable. Linking is combining several object files, along with any
libraries needed (e.g. the standard C library), to produce a file
which can be executed.
The difference is only really apparent when you use several source
files and tell gcc explicitly to do the compiling/linking in two
stages; if you specify `-c', it will compile only, leaving you with a
.o object file for each .c or .cc source file. Then you can call it
again, passing these .o files and suitable arguments, to get an
executable file.
gcc -c file1.c file2.c (compiles only, creating file1.o and file2.o)
gcc file1.o file2.o -o output.exe (links the two object files to form the executable)
--
Regards,
george DOT foot AT merton DOT oxford DOT ac DOT uk
- Raw text -