Configuring DUB to use a 64-bit compiler

How can I configure DUB to compile my application as a 64-bit executable? Here is my dub.json:

{
    "name": "dvulkanbase",
    "targetType": "executable",
    "description": "Vulkan boilerplate",
    "authors": ["Myself"],
    "homepage": "http://something",
    "license": "MIT"
}

      

I tried to add this line to dub.json:

    "dflags-dmd": ["-m64"]

      

but then it dub build

outputs:

## Warning for package dvulkanbase ##

The following compiler flags have been specified in the package description
file. They are handled by DUB and direct use in packages is discouraged.
Alternatively, you can set the DFLAGS environment variable to pass custom flags
to the compiler, or use one of the suggestions below:

-m64: Use --arch=x86/--arch=x86_64/--arch=x86_mscoff to specify the target architecture

Performing "debug" build using dmd for x86.

      

So I tried to replace the line like this:

"dflags-dmd": ["--arch=x86_64"]

      

but got this error:

Error: unrecognized switch '--arch=x86_64'

      

I am on Windows 10, I have DMD 2.074.0 and Visual Studio 2015 and 2017 installed.

+3


source to share


1 answer


I am sure (correct if I am wrong) that you have configured the DMD incorrectly for a 64 bit environment.

Take a look at http://dlang.org/dmd-windows.html#environment . - Key information that you need to install LINKCMD64 correctly. Example:set LINKCMD64=C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\bin\amd64\link.exe

Then you instruct the DMD compiler (with the option -m64

) to compile the D code and use the Microsoft linker to generate a 64-bit executable.



Finally, you will need to modify your JSON or SDL DUB file to contain the correct environment settings. (Look at https://code.dlang.org/package-format?lang=json#target-types )

If you do not specify the environment in the DUB file, you will have to explicitly specify it in the dub build

. Example:dub build --arch=x86_64

+2


source







All Articles