0

所以正如标题中所说,我正在用cl.exefor x86 编译我的 DLL 并使用/MACHINE:X86

这是我的 Makefile :

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

并且输出没有意义

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.

当我为 x86 更改/MACHINE:X64相同的值时,它变得越愚蠢cl.exe所以在这里,cl.exe告诉我这是 x86 的 cl,我正在尝试为 x64 目标编译...

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:X64 /SUBSYSTEM:WINDOWS /OUT:bin\DriverCore.dll
Microsoft (R) C/C++ Optimizing Compiler Version 19.28.29337 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:X64
/SUBSYSTEM:WINDOWS
/OUT:bin\DriverCore.dll
DriverCore.obj
DriverCore.obj : fatal error LNK1112: module machine type 'x86' conflicts with target machine type 'x64'
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.

我在互联网上找不到关于这种行为的解决方案,请帮忙!

4

0 回答 0