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

Installation Guide for Tango used with DMD on Windows

This page details two ways of installing Tango for DMD on Windows. The first is recommended unless you want to hack Tango itself.

For some, it may make more sense to use DSSS for installation, or use a tool like build/bud or rebuild, the alternatives are suggested at further down on the page.

Note: These installation instructions assume a default DMD installation and that the archive has been extracted into C:\, creating C:\dmd as the home of the DMD compiler. The basic goal of this process is to replace Phobos with Tango by placing the Tango object.d and root directories at the head of the DMD include path, and replacing the Phobos libphobos.a with its Tango equivalent of the same name. Note that if your first download of DMD is from the Tango pages, there will be no Phobos to replace.

Install Binary Bundle

  1. Download Tango, one of the .zip options will suffice
  2. Extract the Tango archive into a new directory named C:\dmd\import. If you chose another path, consider avoiding names that contain spaces or parenthesis as these cause problems with some windows command line tools.
  3. Open C:\dmd\bin\sc.ini in a text editor. The contents if tango has not been enabled look like this:
    [Environment]
    LIB="%@P%\..\lib";\dm\lib
    DFLAGS="-I%@P%\..\src\phobos"
    LINKCMD=%@P%\..\..\dm\bin\link.exe
    

As all .ini files in Windows, any line beginning with a semicolon ';' will be considered a comment and will therefore be ignored by DMD. To ensure removal of Tango is as painless as possible, it is a good idea to leave the original lines in the file as comments with the edited line below.

Now, on to the editing:

3.1. Replace the reference to the Phobos include directory in the DFLAGS line with a reference to the Tango root directory. This will ensure that the Tango import modules will be used in place of those in Phobos, and replacing the reference reduces the risk of hard to diagnose compile errors. Either a relative or absolute path may be used, as appropriate:

Relative: "%@P%\..\import"
Absolute: "C:\dmd\import"

e.g. DFLAGS="-I%@P%\..\import"

3.2. Append "-version=Tango" to the DFLAGS line modified above. This version flag is useful for determining whether Tango is the current default library:

e.g. DFLAGS="-I%@P%\..\import" -version=Tango

3.3. Since version 1.023 DMD has a flag to set the name of the runtime library that should be linked in. (It was formerly hardcoded to "phobos.lib" and "libphobos.a") This basically means, you have to append another switch in order to make Tango the standard runtime in your sc.ini:

-defaultlib=tango-base-dmd -debuglib=tango-base-dmd Note: -debuglib is necessary, as of now DMD would fall back to Phobos when compiling with -g.

After making these changes, sc.ini should look like this:

[Environment]
; LIB="%@P%\..\lib";\dm\lib
LIB="%@P%\..\import\lib;%@P%\..\lib;%@P%\..\..\dm\lib"
; DFLAGS="-I%@P%\..\src\phobos"
DFLAGS="-I%@P%\..\import" -version=Tango -defaultlib=tango-base-dmd -debuglib=tango-base-dmd
LINKCMD=%@P%\..\..\dm\bin\link.exe
  1. Please note that while tango-base-dmd.lib and tango-win32-dmd.lib will be automatically linked, tango-user-dmd.lib will not. This is to allow for configurations where tango-user-dmd.lib does not exist (such as when using Bud or Rebuild). To ensure that tango-user-dmd.lib is linked to an application, either of the following two methods should work.
    • a. Add -L+tango-user-dmd.lib to the end of the DFLAGS line in sc.ini.
    • b. Add the following to files being compiled.
      pragma(lib, "tango-user-dmd.lib");
      
    • c. Include tango-user-dmd.lib in the list of files to be compiled when using dmd.exe.

Manual Build and Install

  1. Download or check out Tango sources.
  2. In what follows we assume you've checked out tango into C:\dmd\import. If you chose another path, consider avoiding names that contain spaces or parenthesis as these cause problems with some windows command line tools.
  3. Edit C:\dmd\bin\sc.ini as in point 3 of previous section.
  4. Build tango-base-dmd.lib by running build-dmd.bat in the lib folder. This requires the Digital Mars C compiler and the Digital Mars make utility located in /dm/bin which must be the first 'make' executable encountered in the search path. These tools are both provided by the dmc.zip package linked off the DMD download page: http://www.digitalmars.com/d/dcompiler.html
  5. In the same folder, also run build-win32.bat to create the tango-win32-dmd.lib.
  6. In the same folder, finish building Tango by running build-tango.bat to create the tango-user-dmd.lib.
  7. If you have tango-base-dmd.lib already in your dmd/lib (or where your DMD looks for libraries) directory, it is recommended to back this up (or any other former runtime .lib files that might be replaced).
  8. Place the tango-base-dmd.lib tango-user-dmd.lib and tango-win32-dmd.lib libraries into dmd/lib for the D compiler.
  9. Please note that while tango-base-dmd.lib and tango-win32-dmd.lib will be automatically linked, tango-user-dmd.lib will not. This is to allow for configurations where tango-user-dmd.lib does not exist (such as when using Bud or Rebuild). To ensure that tango-user-dmd.lib is linked to an application, either of the following two methods should work.
    • a. Add -L+tango-user-dmd.lib to the end of the DFLAGS line in sc.ini.
    • b. Add the following to files being compiled:
      pragma(lib, "tango-user-dmd.lib");
      
    • c. Include tango-user-dmd.lib in the list of files to be compiled when using dmd.exe.

Trouble Shooting

Problems you may encounter with the DM toolchain

Using DSSS

DSSS can be used to install Tango, either just the user targeted API, or all of it. All of Tango, including the runtime, can be installed using DSSS' net install feature. Also, if you have installed the runtime, the user API can be installed for use with DSSS by doing

> dsss build
> dsss install

in the Tango root directory.

Using Rebuild / Bud (build)

This is similar to using DSSS (rebuild is indeed a part of DSSS), but where you instead of installing libraries, give the build tools the path to Tango, having the objects rebuilt when needed by the built application.

User Comments

Comments
Author Message

Posted: 02/19/08 16:04:21

I followed the steps in Section "Install Binary Bundle". My compiles have stopped working. I get the following output when doing a compile.

object.d: module object cannot read file 'object.d'

Tool completed with exit code 1

My sc.ini is as follows

[Version] version=7.51 Build 020

[Environment] ;LIB="%@P%\..\lib";\dm\lib LIB="%@P%\..\import\lib;%@P%\..\lib;%@P%\..\..\dm\lib" ;DFLAGS="-I%@P%\..\src\phobos" DFLAGS="-I%@P%\..\import" -version=Tango -defaultlib=tango-base-dmd -debuglib=tango-base-dmd LINKCMD=%@P%\..\..\dm\bin\link.exe

What am I missing?

Posted: 03/06/08 12:38:10

I'm not sure. Could you try the latest binary install and see if it works?

Posted: 04/19/08 18:35:29 -- Modified: 04/19/08 18:36:01 by
cymen

Not related to the above posts but if you download one of the inclusive ZIP files (I grabbed tango-bin-win32-CURRENT-dmd.1.028.zip) it is sufficient to:

1) extract to c:\dmd

2) set path to %PATH%;c:\dmd\bin by doing "PATH=%PATH%;c:\dmd\bin" on the command line or setting it permanently (Control Panel->System->Advanced choose "Environmental Variables" at the bottom and then select Path under "System Variables" and add ";c:\dmd\bin" at the end)

Then hello.d was just a few steps away!

Posted: 07/27/08 12:00:11

Avoid decompressing somewhere where the path have a space (anywhere in "Documents and Settings" is wrong). See my bug report: http://d.puremagic.com/issues/show_bug.cgi?id=2249 BTW, confirming it would be nice, if you can test it.

Posted: 03/10/09 02:02:20

I think there is a error in step 3,assume that the directories "import" and "lib" which in the zip file have been extracted to C:\dmd\import,then we should modify the DFLAGS line as follws:

DFLAGS="-I%@P%\..\import\import" -version=Tango -defaultlib=tango-base-dmd -debuglib=tango-base-dmd

or the compiler will show "object.d: module object cannot read file 'object.d'"