Wiki Roadmap Timeline Tickets New Ticket Source Search Help / Guide About Trac Login

Build Instructions using Phobos/Druntime trunk on Linux/OSX/FreeBSD/Solaris

After LDC for D2 has been build, we can now set up a working LDC environment.

  • Fetch&Compile Phobos/Druntime:
cd ldc/
git clone https://github.com/AlexeyProkhin/phobos
git clone https://github.com/AlexeyProkhin/druntime
cmake -DRUNTIME_DIR=./druntime -DPHOBOS2_DIR=./phobos .
make phobos2
  • Setup target directory for installation (root access required):
mkdir /opt/ldc2
mkdir /opt/ldc2/bin
mkdir /opt/ldc2/import
mkdir /opt/ldc2/lib
  • Install the ldc2 binary and phobos/druntime library
cp bin/ldc2 bin/ldmd2 bin/ldc2.conf /opt/ldc2/bin
cp lib/libdruntime-ldc.a lib/liblphobos2.a /opt/ldc2/lib
cp -r druntime/ phobos/ /opt/ldc2/import
cp -r runtime/import/ldc /opt/ldc2/import
  • Change the contents of /opt/ldc2/bin/ldc2.conf to:
default:
{
    switches = [
        "-I%%ldcbinarypath%%/../import",
        "-I%%ldcbinarypath%%/../import/druntime/import",
        "-I%%ldcbinarypath%%/../import/phobos",
        "-L-L%%ldcbinarypath%%/../lib",
        "-defaultlib=lphobos2",
        "-debuglib=lphobos2"
    ];
};
  • Done! :D

Notes:

  • "object.d: Error: module object cannot read file 'object.d'"; This error indicates that your ldc2.conf is wrong; you may have a stale ldc2.conf around that is used by ldc2 instead.
    To check for other ldc2.conf files on your system you can do "find / -iname "ldc2.conf"". Or put a syntax error into ldc2.conf; if ldc2 isn't complaining, it's using a different ldc2.conf file.
  • You can install ldc2 in some other directory, of course, but you need to adjust some paths!

Playtime

  • Create a file called main.d:
    import std.stdio;
    
    void main()
    {
       printf("Hello World!\n");
    }
    
  • Compile it to verify that LDC with Phobos is working:
    export PATH=/opt/ldc2/bin:$PATH
    ldc2 main.d
    ./main
    
Copyright © 2008, LDC Development Team.