DLL 编译:cl.exe [...] /link /MACHINE:X86 -> 致命错误 LNK1112:模块机器类型“x64”与目标机器类型“x86”冲突

问题描述

正如标题中所说,我正在使用 userId 为 x86 编译我的 DLL 并使用 cl.exe

这里是我的 Makefile:

/MACHINE:X86

并且输出没有意义

#Build DLL in DriverApp/bin/$(IntDir)
SRC  = src\DriverCore.cpp
OUT  = bin\DriverCore.dll

all: $(SRC)

DLL: $(SRC)
    "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.28.29333\bin\HostX86\x86\cl.exe" /w $(SRC) /EHsc /link /DLL /MACHINE:X86 /SUBSYstem:WINDOWS /OUT:$(OUT)

当我为 x86 使用相同的 PS C:\Users\ridap\Documents\GitHub\knx-Communication-Analyser\src\Driver\DriverCore> nmake DLL Microsoft (R) Program Maintenance Utility Version 14.28.29910.0 copyright (C) Microsoft Corporation. All rights reserved. "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.28.29333\bin\HostX86\x86\cl.exe" /w src\DriverCore.cpp /EHsc /link /DLL /MACHINE:X86 /SUBSYstem:WINDOWS /OUT:bin\DriverCore.dll Microsoft (R) C/C++ Optimizing Compiler Version 19.28.29337 for x86 <-- so it's the cl for x86 ! copyright (C) Microsoft Corporation. All rights reserved. DriverCore.cpp Microsoft (R) Incremental Linker Version 14.28.29337.0 copyright (C) Microsoft Corporation. All rights reserved. /out:DriverCore.exe /DLL /MACHINE:X86 /SUBSYstem:WINDOWS /OUT:bin\DriverCore.dll DriverCore.obj libcpmt.lib(uncaught_exception.obj) : Fatal error LNK1112: module machine type 'x64' conflicts with target machine type 'x86' NMAKE : Fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.28.29333\bin\HostX86\x86\cl.exe"' : return code '0x2' Stop. 更改 /MACHINE:X64 时,它变得更愚蠢 所以在这里cl.exe 告诉我它是 x86 的 cl 并且我正在尝试为 x64 目标编译...

cl.exe

我无法在互联网上找到有关此行为的解决方案,请帮忙!

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)