Main Page | Class Hierarchy | Compound List | File List | Compound Members | File Members | Related Pages


Compilation can be done normally using DMD, but dig comes with a program that makes this process much easier, called digc.

This is a compiler wrapper for DMD that creates executables with a single line. Take the examples programs command:

  digc halhello.d / cartoon.d -then=cartoon -windowed -O -release

This first builds halhello.exe using halhello.d as source. The "/" separates programs; they share options. Then it builds cartoon.exe using cartoon.d as source, IF halhello.exe compiled successfully. The "-then" indicates a command to run if all compilation succeeded; in this case it runs the cartoon example.

-windowed compiles these programs as windowed programs; if it's not given, console programs are made instead. You do not need to use "WinMain"; the normal main will work properly.

-O and -release are arguments for DMD; any argument digc doesn't understand is passed along. Note that you don't specify the libraries to use. Instead, digc identifies the necessary libraries automatically, and I'll describe this presently.

To build an executable of a certain name, use "-exe=" followed by the name without extension; for example, "-exe=halhello".

Compiling Libraries

To create a library, use "-lib=" followed by the name without extension. When you compile a library, digc notes the libraries that were given on the command line as well as the filenames themselves, and stores them in a central registry (/dmd/lib/libraries.dat). It is important for the .d files to be compiled in the same way that they would be imported. For example, if a user should import file.d using "import package.file;", then be sure to have "digc package/file.d" when compiling, and not "digc file.d".

This information is used in later compilations to discover what libraries the executable needs to be linked with. digc does this by searching the files for import statements and seeing whether the import file is mentioned in the registry; if so, it includes the library and its dependencies in the command line.

You can create shared libraries - DLLs in Windows - by adding the "-shared" option. For those who have been doing this before: digc automatically creates a DllMain and exports all public symbols. For those who haven't done it before, it makes the program behave similarly to Linux. However, the main program and each DLL will have their own independent GC, so data can't be shared between them.

Generated on Thu Sep 4 13:12:53 2003 for dig by doxygen 1.3.2