Difference between revisions of "Building under Windows"

From D Wiki
Jump to: navigation, search
(Moved from Starting_as_a_Contributor)
 
(link back to contributor guide)
Line 62: Line 62:
 
</syntaxhighlight>
 
</syntaxhighlight>
  
==== Common Windows issues ====
+
== Common Windows issues ==
  
===== Missing MASM386=====
+
=== Missing MASM386===
  
 
If when building druntime you get errors about missing MASM386, it's due to a required assembling of a file called '''minit.asm'''. However the druntime repository includes a prebuilt minit.obj file so you shouldn't need to assemble it again. As a workaround for the make error create an empty '''masm386.bat''' file and put it in a directory that's in your '''PATH'''.
 
If when building druntime you get errors about missing MASM386, it's due to a required assembling of a file called '''minit.asm'''. However the druntime repository includes a prebuilt minit.obj file so you shouldn't need to assemble it again. As a workaround for the make error create an empty '''masm386.bat''' file and put it in a directory that's in your '''PATH'''.
Line 70: Line 70:
 
It's also recommended that you use the cmd.exe terminal. Others, like PowerShell, are known to experience issues with legacy tools.
 
It's also recommended that you use the cmd.exe terminal. Others, like PowerShell, are known to experience issues with legacy tools.
  
===== Intermediate files lead to several errors =====
+
=== Intermediate files lead to several errors ===
  
 
The three main components (dmd, druntime, phobos) should always be built together with matching versions. The intermediate files generated by a previous build can lead to a failure so it's advisable to run
 
The three main components (dmd, druntime, phobos) should always be built together with matching versions. The intermediate files generated by a previous build can lead to a failure so it's advisable to run
Line 79: Line 79:
  
 
on each component before starting the process.
 
on each component before starting the process.
 +
 +
== Where to go from here ==
 +
 +
If you want to contribute to a D project, please continue with the [[Starting_as_a_Contributor] starting a a contributor]] guide.
 +
If you want to contribute to Phobos, you may also read the [[Contributing to Phobos|contributing to Phobos guide]].

Revision as of 04:47, 22 August 2016

Prerequisites

On Windows, you will need Git for Windows, the DigitalMars C++ compiler, and, for 64-bit or 32-bit COFF builds, the Microsoft Windows SDK.

Building D

The following instructions work for win32. May or may not work with win64. This scheme is a suggestion. These instructions should work when building from a clean repository, however, this repository contains autogenerated code that may be left behind after switching branches so running a git clean after switching branches is a good idea:

git clean -xfd

Assuming your sources are checked out C:\D, and that make from digital mars is in your path, you can do the following to build them:

set DM_HOME=C:\D
cd %DM_HOME%\dmd2\src\dmd\src
make -fwin32.mak release

From there, it is suggested to move the built binaries into your %DM_HOME%\windows\bin directory, and add that to your path:

copy *.exe %DM_HOME%\dmd2\windows\bin
set path=%path%;%DM_HOME%\dmd2\windows\bin

From there, you have to create a sc.ini in your DMD.exe directory. It is suggested to just copy paste the one provided in the packaged 2.107.0, instead of writing your own.

Now build druntime:

cd %DM_HOME%\dmd2\src\druntime
make -fwin32.mak

And phobos:

cd %DM_HOME%\dmd2\src\phobos
make -fwin32.mak

You should copy the phobos lib into your windows\lib folder:

copy phobos.lib %DM_HOME%\dmd2\windows\lib

Optionally, you can build rdmd from source if you have checked out tools in your sources:

cd %DM_HOME%\dmd2\src\tools
make -fwin32.mak rdmd.exe
copy *.exe %DM_HOME%\dmd2\windows\bin

The last step is getting the additional libs. curl for D2 can be found at the bottom of the download section of dlang.org: [download].

Additional libs that are necessary can simply be copy pasted from the 2.107.0 package (without overwriting your phobos.lib)

The very last step is to verify that everything works by unittesting phobos:

cd %DM_HOME%\dmd2\src\phobos
make -fwin32.mak unittest

Common Windows issues

Missing MASM386

If when building druntime you get errors about missing MASM386, it's due to a required assembling of a file called minit.asm. However the druntime repository includes a prebuilt minit.obj file so you shouldn't need to assemble it again. As a workaround for the make error create an empty masm386.bat file and put it in a directory that's in your PATH.

It's also recommended that you use the cmd.exe terminal. Others, like PowerShell, are known to experience issues with legacy tools.

Intermediate files lead to several errors

The three main components (dmd, druntime, phobos) should always be built together with matching versions. The intermediate files generated by a previous build can lead to a failure so it's advisable to run

make -fwin32.mak clean

on each component before starting the process.

Where to go from here

If you want to contribute to a D project, please continue with the [[Starting_as_a_Contributor] starting a a contributor]] guide. If you want to contribute to Phobos, you may also read the contributing to Phobos guide.