【发布时间】:2017-05-19 15:23:23
【问题描述】:
如何配置 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。
【问题讨论】:
-
您是否尝试手动编译和链接一个小型 D 程序?我怀疑你没有配置你的环境。如您所知,DUB 正在使用编译器/链接器 - 如果您没有正确设置它,编译/链接将失败。可能根本不是 DUB 问题...对于链接,如果我没记错的话,DMD 使用 Microsoft 链接器。
-
我可以编译和链接其他 D 程序,但这是我第一次尝试构建 64 位程序并运行
dmd --arch=x86_64 source\app.d给出相同的错误。 -
据我所知 dmd 没有该选项。它只有
-m64...这正是我问的 - 你能成功编译(使用 DMD)你想要的目标吗??? -
是的,刚刚测试过。命令行上的dmd支持
-m64,但是在dub中不行。 -
dub build --arch=x86_64应该在一切配置良好的情况下进行。