3

如何配置 DUB 以将我的应用程序编译为 64 位可执行文件?这是我的 dub.json:

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

我尝试将此行添加到 dub.json:

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

但随后dub build输出:

## 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.

所以我尝试用以下内容替换该行:

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

但收到此错误:

Error: unrecognized switch '--arch=x86_64'

我在 Windows 10 上,安装了 DMD 2.074.0 和 Visual Studio 2015 和 2017。

4

1 回答 1

2

我很确定(如果我错了,请纠正我)您没有为 64 位环境正确配置 DMD。

看看http://dlang.org/dmd-windows.html#environment。- 关键信息是您需要正确设置 LINKCMD64 变量。例子:set LINKCMD64=C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\bin\amd64\link.exe

然后您指示 DMD 编译器(带有-m64选项)编译 D 代码并使用 Microsoft 的链接器生成 64 位可执行文件。

最后,您需要修改 JSON 或 SDL DUB 文件以包含正确的环境设置。(看看https://code.dlang.org/package-format?lang=json#target-types

如果你没有在 DUB 文件中指定环境,你必须在你的dub build. 例子:dub build --arch=x86_64

于 2017-05-19T15:52:47.073 回答