Search code examples
compiler-construction64-bitd

64-bit executables with DMD


I'm a bit confused about the -m64 switch on the DMD compiler. Specifically, the documentation for it says this:

Compile a 64 bit executable. The generated object code is in MS-COFF and is meant to be used with the Microsoft Visual Studio 10 or later compiler.

Now, I've tried to use it with my own .d files, and it's always failed with the following message:

Can't run '\bin\link.exe', check PATH

Does this mean I need to have a copy of Microsoft Visual Studio 10 (or later) to compile 64-bit executables? As you might have guessed, I'm on Windows 7.


Solution

  • Generation of 64bit executables on Windows requires configuration of DMD. It does not work out of box unfortunately. It is all explained on the "Windows notes" page.

    In short, you need to set environment variable LINKCMD64 to a valid Microsoft linker. You may do this from the command line, before you run dmd, by executing set LINKCMD64=C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\bin\amd64\link.exe . Problem with this is that it is a temporal solution. I prefer setting a persistent environment variable LINKCMD64.

    "How to Create a Environmental Variable Windows 7" is a good article which shows how to create environment variables on Windows 7.

    PS. You do not need to buy Visual Studio. Visual Studio Express (C++) contains the linker. I believe Platform SDK too. There was a package which contains just the compiler, linker and all necessary tools to build Windows applications, but I do not remember the name of that package.