DMD 1.030 and 2.014 releases

"Jérôme M. Berger" jeberger at free.fr
Sat May 17 12:53:14 PDT 2008


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Walter Bright wrote:
> davidl wrote:
>> Added -lib switch to generate library files. Also causes multiple
>> object files to be generated from one source module. <-- what does
>> this exactly mean
>>
>> We need more docs on this.
> 
> http://www.digitalmars.com/d/2.0/dmd-windows.html#library

	This isn't very clear for people who don't already know how the
linker works and what static libraries are. Here's a go at something
more complete:

	When you create an executable (or a shared library), the linker
takes all the object files that you specified and glues them
together. It also translates all the external references, so that if
you use function "foo" in file a.o and this function is defined in
file b.o it will modify the code of a.o to point the implementation
of "foo".

	Static libraries are just collections of *optional* additional
object files. This means that if you have an object file c.o in a
static library and nobody refers to it, then it won't be included in
the executable, but if you use one function in c.o, then the *whole*
object file is included.

	The usual way to make object files is that one source file gives
one object file. This means that if you want to avoid executable
bloat, you need to split your source files so that people can call
one function without bringing in a lot of unnecessary functions that
just happened to be defined in the same file.

	What the "-lib" option does is to automagically split the files so
that a single source file will generate several small object files
instead of a single big one. This way you don't need to split your
source code into lots of small files if you don't want to, and your
executables won't become unnecessarily big from all those extra
functions.

		Jerome
- --
+------------------------- Jerome M. BERGER ---------------------+
|    mailto:jeberger at free.fr      | ICQ:    238062172            |
|    http://jeberger.free.fr/     | Jabber: jeberger at jabber.fr   |
+---------------------------------+------------------------------+
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.7 (GNU/Linux)

iD8DBQFILzeqd0kWM4JG3k8RAtzmAJ9M4wIEe+KU7M5akehypBOfg5feKgCgsqTw
xLLOuj4Cvj/PkjjgSjumQ2E=
=6Nba
-----END PGP SIGNATURE-----


More information about the Digitalmars-d-announce mailing list