TIP: Click on subject to list as thread! ANSI
echo: c_echo
to: David Burns
from: Darin McBride
date: 1998-07-11 22:31:16
subject: Re: Compiler, linker, assembler

DB> Why can't a compiler have one built in to create an executable?
AR> 
AR> Current compilers usually _have_ one built in. ;-)

 DB> No, but why in some would you want to compile your 
 DB> source into an Object code file?  surely it's useless 
 DB> in this format, so why would you want to manually 
 DB> compile and link?  surely you'd need to link it to do 
 DB> anything with it?

As you get into more advanced issues, you can really appreciate the
compile-link two-step we do.  For example, if you can use Pascal or Fortran
to create object files of the same format, you can link them all together
and create an executable that has some C, some Fortran, some Pascal in it. 
You can now harness the power of Fortran (in the areas that Fortran excels)
in your C code - using the best tool for each job.  Another example is one
at work where we want the same C code linked into multiple DLLs - we
compile it once, link it in three places.  If we change the C code, next
time we rebuild, all three will get the changes.

Less spectacular is when you have two C files to combine - and you only
change one.  Rather than recompiling the unchanged code, you leave it
compiled in the obj format - you compile the changed code, create its obj
file, and then link the two (or three, or four, or dozens!) files together.
 Combined with make utilities (which can semi-automatically determine which
files need to be recompiled), when you change little, little needs to be
recompiled.  This can result in a lot of saved time when you're debugging -
modifying your code and recompiling very often.

It merely grants an extra level of control.  However, if you're not
interested, most compilers will auto-link for you.  For example, with gcc,
I often just do:

gcc myfile.c

This will, most of the time, create myfile.exe, and the .obj file (well,
with gcc, it's .o, but that's mostly irrelevant) is never
"created" (well, again, it is, but it's automatically deleted
afterwards).  As soon as I go to two source modules, however, I usually
separate the compile & link stages out to save me time in the long run.

Hope this helps,


---
* Origin: Tanktalus' Tower BBS (1:250/102)
SEEN-BY: 396/1 622/419 632/371 633/260 267 270 371 634/397 635/506 728
SEEN-BY: 639/252 670/213 218
@PATH: 250/102 201 99 396/1 633/260 635/506 728 633/267

SOURCE: echomail via fidonet.ozzmosis.com

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.