Building the Derelict Packages

It is recommended that when you use Derelict you first build the packages you need via the supplied makefiles or supported IDE project files, even if you are using a build tool that allows you to bypass this step. Doing so places all of the Derelict libraries in one convenient location and generates D Interface (.di) files in a hierarchy, independent of the package tree, that make it easier to import Derelict into your applications.

All Platforms

Make files have been created for the platforms Derelict currently supports. They are designed to be configurable to some degree. Configuration options will be discussed shortly. First, let's get straight into compiling.

In order to build the packages via the make files, you must execute the make command with the -f command line option to specify the platform-specific make file. You must also specify a compiler to use via the DC variable. Henceforth, this documentation will refer to the top-level Derelict directory as $(DERELICT).


# on Windows
make -fwin32.mak DC=dmd

#on Linux or FreeBSD
make -flinux.mak DC=dmd

#on MacOS X
make -fmac.mak DC=dmd
This will build all Derelict packages into several libraries in the $(DERELICT)/lib directory. It will also create a hierarchy of .di files in $(DERELICT)/import. When compiling your application, you can easily add these paths to your build so that your compiler can find the files. The output path for both the libraries and the .di files is configurable.

The following table shows supported compilers and the values that should be passed as the DC parameter when executing make.

CompilerDC Value

The default name of each compiled library is that of the package (DerelictGL.lib, DerelictOgg.lib, etc..., on Windows, and libDerelictGL.a, libDerelictOgg.a, etc..., on other platforms). However, some Derelict packages bind to multiple shared libraries. For example, DerelictGL includes bindings for both OpenGL and GLU. Issuing the above make commands without specifying any targets results in all bindings in a package being compiled into a single library file. But there are targets to build each binding into separate libraries. Doing so will result in some libraries named differently than the package. They will be named the same as the make target instead.

make -fwin32.mak DerelictGL DerelictGLU DC=dmd

This results in two libraries being generated, DerelictGL.lib and DerelictGLU.lib. You can also build both libraries by using, in this case, the DerelictGL_ALL make target. Each package has a $(PACKAGENAME)_ALL target that will build all libraries implemented by that package. The individual make targets supported for each package can be found in the package-specific documentation.

There are also four cleanup targets.

Configuring the make-based build system can be done by modifying the files found in $(DERELICT).inc. There, you will find the following files:

Compiler Config

There is only one configurable option in the compiler include files: DFLAGS. Consider the other options hardcoded. The DFLAGS variable allows you to specify compiler options to control the build output. By default, it is set to fully optimize the generated code. This is where you would make the changes necessary to build debug versions of the libraries, or to add any other option that directly affects the generated code. This is not where you adjust the locations of the .di files or the libraries themselves. That is handled in the platform configuration files.

Platform Config

There are two configurable options in each platform-specific include: LIB_DEST and IMPORT_DEST. The former determines where the compiled library files will be output, while the latter specifies the output path for the generated .di files. You can change these to any valid path on your system.


Aside from the make file build system described above, project files are also provided for the VisualD IDE. To build via VisualD, follow these steps.
  1. From within VisualD, go to File->Open->Project/Solution (or pres Ctrl-Shift-O).
  2. In the file selection window, navigate to $(DERELICT)/project/visuald and select the file Derelict.sln.
  3. In the toolbar, selecte the build configuration you want (Release or Debug -- usually you'll want Release).
  4. You can alternatively press Ctrl-Shift-B or right-click on the solution in the Solution Explorer window and select 'Build Solution from the popup menu to build all packages, or you can right click on any of the project names in the Solution Explorer window and select 'Build' to build individual packages.
As with the make-based build system, libraries are created in $(DERELICT)/lib and .di files in $(DERELICT)/import by default. You can change this for each build configuration in the settings dialog for each project. Unfortunately, I don't know of a way to configure this globally.