Download Reference Manual
The Developer's Library for D
About Wiki Forums Source Search Contact

Note: This howto applies to the GDC from sourceforge.

GDC Installation

This page tells you how to compile GDC from sources and also install compiled Tango sources.
It's designed to be mostly copy&paste.

For MacOS users: A patched Apple GCC is desirable to get better support (unversial binaries etc.) instead of patching the ordinary GCC as it is shown here. Prebuild packages are available.

GDC Installation from binary distribution

The binary distribution of GDC can be retrieved at SourceForge. Chose the appropriate file according to what operating system you run. The archives are all bzipped, which means you need either bunzip2, or another program that supports the format.

All archives have a common structure according to the directories you find in /usr on a common Unix-like operating system:

  • gdc/
    • bin/
    • include/
    • lib/
    • libexec/
    • man/
    • share/

The easiest way to achieve a correct installation of GDC is to just copy the whole content of the gdc/ directory into a directory of your choice (/usr/local or /usr, if you have root access to your development/evaluation machine).

If you feel like doing a special installation, be aware of the fact that this could lead to a corrupt or not fully functional installation.

GDC Installation from source

These instructions apply for the SourceForge Subversion GDC repository. In case you already have GDC installed in an appropriate version, you can skip this section.


You need at least these programs installed for the next steps. Most of them are probably already installed.

  • curl or wget
  • bzip2
  • tar
  • patch
  • svn (subversion)
  • c++ (or g++; you may want to do "ln -s /usr/bin/g++ /usr/bin/c++")
  • GMP and MPFR ("apt-get install libgmp3-dev libmpfr-dev")

Getting GCC

Get the GCC sources from You need at least the gcc-core-x.x.x file, or the gcc-x.x.x file if you want the full GCC collection.

curl -o gcc-core-4.3.1.tar.bz2 
curl -o gcc-g++-4.3.1.tar.bz2 

Getting GDC

For the latest GDC you would do

svn co

which creates the d directory.

Compiling GDC

This will be shown keeping separate directories for the sources and the compiled binaries.

1. Extract the GCC sources to an empty directory

mkdir gdc-sf
cd gdc-sf
tar xjf ../gcc-core-4.3.1.tar.bz2 
tar xjf ../gcc-g++-4.3.1.tar.bz2 

on Macintosh 10.5 you may have to change "--strip-underscores" to "--strip-underscore" in "gcc-4.3.1/libstdc++-v3/scripts/".

2. Copy the GDC sources to the GCC directory, and run the setup script.

cd gcc-4.3.1/gcc
cp -R ../../../d .
cd ..

3. Create a new empty directory for building.

cd ..
mkdir build
cd build

4. Configure, make, make install.

Don't forget to enable all languages you want to use. (add --disable-multilib on x64 systems)

../gcc-4.3.1/configure --enable-languages=c,c++,d --enable-static --disable-shared --prefix=$HOME/d/gdc024
sudo make install


  • "--prefix" is optional and points to the place where all GDC files will go on "make install".
  • "--enable-static --disable-shared" are optional but may prevent some errors like "version `GCC_4.2.0' not found".
  • "c,c++", is optional, you can drop it to speed up compile times.

On Macintosh you might want to replace the previous commands with

../gcc-4.3.1/configure --prefix=$HOME/d/gdc024 --disable-nls --disable-multilib --enable-languages=c,c++,d
sudo make install

5. Test

export PATH=$HOME/d/gdc024/bin:$PATH
gdc --version

You might want to put the export lines into your ~/.bash_profile file.

Install Tango

Note: This part isn't fully adjusted to gcc 4.3 yet

When you have compiled the Tango library (steps 1 and 2) you can add the Tango files to your GDC installation.
It is assumed that GDC was installed in ~/d/gdc024 and Tango in ~/trunk. Change the paths as necessary.

export TRUNK=~/trunk
export GDC=~/d/gdc024

cd $(GDC)
rm -rf include/d/4.3.1/object.d
rm -rf include/d/4.3.1/std/
rm -rf lib/libgphobos.a

cd $(TANGO)
cp -r object.d std/ tango/ $(GDC)/include/d/4.3.1/
cp -r lib/libgphobos.a lib/libgtango.a $(GDC)/lib/

Now create some Hello World program in a file called main.d:


void main()
  Stdout("Hello World").newline;

And try to compile it:

gdc main.d -o main -fversion=Posix -fversion=Tango -I$(GDC)/include/d/4.3.1 -L$(GDC)/lib -lgtango


  • If GDC was not found, you have to extend your PATH variable.