【问题标题】:Qt5Quickd.lib(Qt5Quickd.dll) : fatal error LNK1112: module machine type 'x64' conflicts with target machine type 'x86'Qt5Quickd.lib(Qt5Quickd.dll):致命错误 LNK1112:模块机器类型“x64”与目标机器类型“x86”冲突
【发布时间】:2019-08-05 05:17:09
【问题描述】:

我正在尝试使用命令行而不是 QtCreator GUI 工具构建 Qt 应用程序。我通过运行以下命令来使用 VS 2017 的开发人员命令提示符

"C:\Qt\Qt5.13.0\5.13.0\msvc2017_64\bin\qmake.exe" ..\qt3dsceneeditor.pro -spec win32-msvc "CONFIG+=debug" "CONFIG+=qml_debug"
"C:\Qt\Qt5.13.0\Tools\QtCreator\bin\jom.exe" -f ../../build-qt3dsceneeditor-Desktop_Qt_5_13_0_MSVC2017_64bit-Debug/Makefile qmake_all
"C:\Qt\Qt5.13.0\Tools\QtCreator\bin\jom.exe"

构建过程一切正常,直到遇到此错误的link 阶段:

link /NOLOGO /DYNAMICBASE /NXCOMPAT /DEBUG /DLL /SUBSYSTEM:WINDOWS /MANIFEST:embed /OUT:debug\editorlib.dll @C:\Users\me\AppData\Local\Temp\editorlib.dll.13948.102703.jom
Qt5Quickd.lib(Qt5Quickd.dll) : fatal error LNK1112: module machine type 'x64' conflicts with target machine type 'x86'
jom: C:\Users\me\repos\qt3d-editor\scripts\editorlib\Makefile.Debug [debug\editorlib.dll] Error 1112
jom: C:\Users\me\repos\qt3d-editor\scripts\editorlib\Makefile [debug] Error 2
jom: C:\Users\me\repos\qt3d-editor\scripts\Makefile [sub-editorlib-make_first-ordered] Error 2

我研究了其他人报告的类似错误,提到我需要更改Visual Studio配置。但就我而言,我没有使用 VS GUI。如何更改 VS 2017 的开发人员命令提示符 上的配置?

如果有人可以介绍使用命令行工具而不是 QtCreator GUI 构建 Qt 应用程序的良好指南,我将不胜感激!

正如@code_fodder 所建议的,我正在查看 QtCreator 日志。 QtCreator 编译/链接没有任何错误:

命令行的错误是:

我也尝试使用nmake 而不是jom,它遇到了同样的错误:

echo Setting up environment for Qt usage...
set PATH=C:\Qt\Qt5.13.0\5.13.0\msvc2017_64\bin;%PATH%
echo --------------------------------------
mkdir C:\Users\me\repos\build
cd C:\Users\me\repos\build\
qmake.exe -makefile C:\Users\me\repos\qt3d-editor\qt3dsceneeditor.pro
nmake /u /f Makefile

更新

在 Linux 上,我不会遇到这样的错误。在 openSUSE Leap 15.1 上,这个脚本运行良好:

#!/bin/sh 

export PATH=~/Qt5.13.0/5.13.0/gcc_64/bin/:$PATH 
mkdir build 
cd build 
qmake ../qt3dsceneeditor.pro -spec linux-icc-64 CONFIG+=qtquickcompiler 
make -j4

【问题讨论】:

  • 您的问题似乎暗示这可以通过 Qt Creator (GUI) 项目工作? - 本质上 Qt Creator 仍然调用 qmake(如果需要),你应该能够看到 Qt Creator 正在做什么的输出 - 查看编译输出选项卡(如果你没有打开它,你可以告诉 qt creator 显示它已经)。但是你确定你想要-spec win32-msvc吗?看起来你拥有的 Qt 库是 64 位库 - 你有 32 位库吗?
  • @code_fodder 谢谢。对,我查看编译 coutput 选项卡并查看 QtCreator 日志。出于某种原因,Qt Creator 正在使用-spec win32-msvc 选项:13:24:01: Starting: "C:\Qt\Qt5.13.0\5.13.0\msvc2017_64\bin\qmake.exe" C:\Users\me\repos\qt3d-editor\qt3dsceneeditor.pro -spec win32-msvc "CONFIG+=debug" "CONFIG+=qml_debug"
  • hmm... 我建议您的“环境”与 Qt Creator 中使用的不同。我对 Qt 有点生疏,因为我已经有一段时间没有使用它了,但是我认为您可以查看 Qt Creator GUI 中设置的环境变量 - 它们可能与您在命令行上使用的不同。现在,我不记得您是否可以通过 Qt Creator GUI 获得命令提示符 - 但您可以更改构建设置以运行命令行而不是自动调用 qmake 等......所以在那里您可以测试您的手动命令+ 参数,看看它是否在 Qt Creator 中工作。之后(应该...
  • ...工作您可能需要通过路径等找到不同之处。您可能正在寻找指定 Qt 库所在位置的路径,并在您的 cmd shell 中设置它们。可能值得有一个脚本来执行此操作(设置环境变量,然后调用 cmd.exe),然后您可以从 Qt GUI 复制环境...
  • @code_fodder 谢谢。没错,我要处理环境变量。

标签: c++ windows qt makefile qmake


【解决方案1】:

这个脚本解决了问题:

set PATH=C:\Qt\Qt5.13.0\5.13.0\msvc2017_64\bin;%PATH%
set PATH=C:\Qt\Qt5.13.0\Tools\QtCreator\bin;%PATH%
mkdir C:\Users\me\repos\qt3d-editor\scripts\build-deploy\temp
cd C:\Users\me\repos\qt3d-editor\scripts\build-deploy\temp
qmake.exe C:\Users\me\repos\qt3d-editor\qt3dsceneeditor.pro -spec win32-msvc "CONFIG+=qtquickcompiler"
jom.exe qmake_all
jom.exe

我不确定哪个修改解决了这个问题。


在调试模式下构建也很好:

qmake.exe C:\Users\me\repos\qt3d-editor\qt3dsceneeditor.pro -spec win32-msvc "CONFIG+=debug" "CONFIG+=qml_debug"

我在 VS 2017 的 x64 Native Tools 命令提示符上运行脚本:

【讨论】:

    猜你喜欢
    • 2011-04-03
    • 2012-02-06
    • 2021-08-10
    • 1970-01-01
    • 2013-01-20
    • 2013-04-19
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多