无法检测到 Visual Studio 在配置 QPdf 和 QWebEngine 时。

huangapple go评论98阅读模式
英文:

Cannot detect Visual Studio when configuring QPdf and QWebEngine

问题

我无法配置 QPdf 和 QWebEngine,因为 configure.bat 认为我没有安装 Visual Studio 2019 或更高版本,但我已经安装了 Visual Studio 2022。我按照 https://doc.qt.io/qt-6/windows-building.htmlhttps://doc.qt.io/qt-6/qtwebengine-platform-notes.html 中的说明操作。

这是确切的错误消息:

警告:QtWebEngine 将不会构建。构建需要 Visual Studio 2019 或更高版本。
警告:QtPdf 将不会构建。构建需要 Visual Studio 2019 或更高版本。

我尝试将生成器从 Ninja 切换到 Visual Studio 17 2022,但问题仍然存在。事实上,这使得配置过程中的其他事情失败了。

我已经在 https://bugreports.qt.io/browse/QTBUG-114875 上发布了这个问题。那里的评论说我没有运行 vcvarsall.bat,但事实上我确实运行了它,因为它是 Qt 文档中概述的过程的一部分。

英文:

I cannot configure QPdf and QWebEngine because configure.bat thinks I do not have Visual Studio 2019 or higher, but I have Visual Studio 2022 installed.  I followed the instructions https://doc.qt.io/qt-6/windows-building.html and https://doc.qt.io/qt-6/qtwebengine-platform-notes.html.

Here is the exact error message:

WARNING: QtWebEngine won't be built. Build requires Visual Studio 2019 or higher.
WARNING: QtPdf won't be built. Build requires Visual Studio 2019 or higher.

I tried switching the generator from Ninja to Visual Studio 17 2022, but the problem still persisted. In fact, it made it worse by making other things fail in the configuration process.

I posted this to https://bugreports.qt.io/browse/QTBUG-114875. The comments there said I was not running the vcvarsall.bat, but I was in fact doing that because it was part of the process outlined in Qt's documentation.

答案1

得分: 0

这是要翻译的内容:

"嗯,我想我找到了解决问题的方法。我有两个单独的脚本:1)pre-configure.bat 用于运行 vcvarsall 脚本,2)run-configure.bat 用于调用 configure.bat 脚本。我先运行了 pre-configure.bat,然后运行 run-configure.bat。这生成了以下输出:

PS C:\Qt\6.2.4\build> .\pre-configure.bat
C:\Qt\6.2.4\build>ECHO OFF
设置 Microsoft Visual Studio 2022。
通过提供 ARCH(x86、amd64 等)、MSVS_VCVARS_SCRIPT_PATH(vcvarsall.bat 的路径)、QT_VERSION 和 QT_SOURCE_DIR(可选)来编辑此脚本。


** Visual Studio 2022 Developer Command Prompt v17.6.4
** 版权所有 (c) 2022 Microsoft Corporation


[vcvarsall.bat] 环境已初始化为:'x64'
PS C:\Qt\6.2.4\build> .\run-configure.bat
C:\Qt\6.2.4\build>ECHO OFF
配置 Qt 构建为“6.2.4”。
配置 Qt 以发布配置构建。
配置 Qt 以部署到“C:\Qt\6.2.4\release\bin”。
QT_LLVM_CLANG_DIR 为“C:\Qt\llvm-develop-install\release”。

  • cd qtbase
  • C:\Qt\6.2.4\source\qtbase\configure.bat -top-level -prefix “C:\Qt\6.2.4\release\bin” -release -feature-clang -feature-clangcpp -- -D LLVM_INSTALL_DIR=“C:\Qt\llvm-develop-install\release”
    -- Windows 10 SDK 版本:
    'C:/Program Files/CMake/bin/cmake.exe' '-D' 'LLVM_INSTALL_DIR=C:\Qt\llvm-develop-install\release' '-DCMAKE_INSTALL_PREFIX=C://Qt//6.2.4//release//bin' '-DCMAKE_BUILD_TYPE=Release' '-DINPUT_clang=yes' '-DINPUT_clangcpp=yes' '-G' 'Ninja' 'C:/Qt/6.2.4/source'
    -- CXX 编译器标识是 GNU 8.3.0
    -- C 编译器标识是 GNU 8.3.0
    -- ASM 编译器标识是 GNU
    -- 找到汇编程序:C:/Strawberry/c/bin/gcc.exe
    -- 正在检测 CXX 编译器 ABI 信息
    -- 检测 CXX 编译器 ABI 信息 - 完成
    -- 检查可工作的 CXX 编译器:C:/Strawberry/c/bin/c++.exe - 跳过
    -- 检测 CXX 编译器功能
    -- 检测 CXX 编译器功能 - 完成
    -- 正在检测 C 编译器 ABI 信息
    -- 检测 C 编译器 ABI 信息 - 完成
    -- 检查可工作的 C 编译器:C:/Strawberry/c/bin/gcc.exe - 跳过
    -- 检测 C 编译器功能
    -- 检测 C 编译器功能 - 完成

显然,这并没有起作用。我在 run-configure.bat 脚本中调用了 pre-configure.bat,并且它能够检测到 MSVC 作为编译器。这生成了以下输出:

PS C:\Qt\6.2.4\build> .\run-configure.bat
C:\Qt\6.2.4\build>ECHO OFF
设置 Microsoft Visual Studio 2022。
通过提供 ARCH(x86、amd64 等)、MSVS_VCVARS_SCRIPT_PATH(vcvarsall.bat 的路径)、QT_VERSION 和 QT_SOURCE_DIR(可选)来编辑此脚本。


** Visual Studio 2022 Developer Command Prompt v17.6.4
** 版权所有 (c) 2022 Microsoft Corporation


[vcvarsall.bat] 环境已初始化为:'x64'
配置 Qt 构建为“6.2.4”。
配置 Qt 以发布配置构建。
配置 Qt 以部署到“C:\Qt\6.2.4\release\bin”。
QT_LLVM_CLANG_DIR 为“C:\Qt\llvm-develop-install\release”。

  • cd qtbase
  • C:\Qt\6.2.4\source\qtbase\configure.bat -top-level -prefix “C:\Qt\6.2.4\release\bin” -release -feature-clang -feature-clangcpp -- -D LLVM_INSTALL_DIR=“C:\Qt\llvm-develop-install\release”
    -- Windows 10 SDK 版本: 10.0.22621.0
    'C:/Program Files/CMake/bin/cmake.exe' '-D' 'LLVM_INSTALL_DIR=C:\Qt\llvm-develop-install\release' '-DCMAKE_INSTALL_PREFIX=C://Qt//6.2.4//release//bin' '-DCMAKE_BUILD_TYPE=Release' '-DINPUT_clang=yes' '-DINPUT_clangcpp=yes' '-G' 'Ninja' 'C:/Qt/6.2.4/source'
    -- CXX 编译器标识是 MSVC 19.36.32535.0
    -- C 编译器标识是 MSVC 19.36.32535.0
    -- ASM 编译器标识是 MSVC
    -- 找到汇编程序:C:/Program Files/Microsoft Visual Studio/2022/Community/VC/Tools/MSVC/14.36.32532/bin/Hostx64/x64/cl.exe
    -- 正在检测 CXX 编译器 ABI 信息
    -- 检测 CXX 编译器 ABI 信息 - 完成
    -- 检查可工作的 CXX 编译器:C:/Program Files/Microsoft Visual Studio/2022/Community/VC/Tools/MSVC/14.36.32532/bin/Hostx64/x64/cl.exe - 跳过
    -- 检测 CXX 编译器功能
    -- 检测 CXX 编译器功能 - 完成
    -- 正在检测 C 编译器 ABI 信息
    -- 检测 C 编译器 ABI 信息 - 完成
    -- 检查可工作的 C
英文:

Well, I think I found a solution to the problem.  I had two separate scripts:  1) pre-configure.bat to run the vcvarsall script and 2) run-configure.bat to call the configure.bat script.  I ran pre-configure.bat and then run-configure.bat.  That generates the following output

PS C:\Qt.2.4\build> .\pre-configure.batC:\Qt.2.4\build>ECHO OFF
Set up Microsoft Visual Studio 2022.
Edit this script by providing the ARCH (x86, amd64, et cetera), the MSVS_VCVARS_SCRIPT_PATH (the path to the vcvarsall.bat), the QT_VERSION, and the QT_SOURCE_DIR (optional).
**********************************************************************
** Visual Studio 2022 Developer Command Prompt v17.6.4
** Copyright (c) 2022 Microsoft Corporation
**********************************************************************
[vcvarsall.bat] Environment initialized for: 'x64'
PS C:\Qt.2.4\build> .\run-configure.batC:\Qt.2.4\build>ECHO OFF
Configuring build for Qt "6.2.4".
Configuring Qt to build in -release configuration.
Configuring Qt to deploy to "C:\Qt.2.4\release\bin".
QT_LLVM_CLANG_DIR is "C:\Qt\llvm-develop-install\release".
+ cd qtbase
+ C:\Qt.2.4\source\qtbase\configure.bat -top-level -prefix "C:\Qt.2.4\release\bin" -release -feature-clang -feature-clangcpp -- -D LLVM_INSTALL_DIR="C:\Qt\llvm-develop-install\release"
-- Windows 10 SDK version:
'C:/Program Files/CMake/bin/cmake.exe' '-D' 'LLVM_INSTALL_DIR=C:\\Qt\\llvm-develop-install\\release' '-DCMAKE_INSTALL_PREFIX=C://Qt//6.2.4//release//bin' '-DCMAKE_BUILD_TYPE=Release' '-DINPUT_clang=yes' '-DINPUT_clangcpp=yes' '-G' 'Ninja' 'C:/Qt/6.2.4/source'
-- The CXX compiler identification is GNU 8.3.0
-- The C compiler identification is GNU 8.3.0
-- The ASM compiler identification is GNU
-- Found assembler: C:/Strawberry/c/bin/gcc.exe
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: C:/Strawberry/c/bin/c++.exe - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: C:/Strawberry/c/bin/gcc.exe - skipped
-- Detecting C compile features
-- Detecting C compile features - done

Apparently, that did not work.  I called pre-configure.bat as part of the run-configure.bat script and it was able to detect MSVC as the compiler.  That generates the following output

PS C:\Qt.2.4\build> .\run-configure.batC:\Qt.2.4\build>ECHO OFF
Set up Microsoft Visual Studio 2022.
Edit this script by providing the ARCH (x86, amd64, et cetera), the MSVS_VCVARS_SCRIPT_PATH (the path to the vcvarsall.bat), the QT_VERSION, and the QT_SOURCE_DIR (optional).
**********************************************************************
** Visual Studio 2022 Developer Command Prompt v17.6.4
** Copyright (c) 2022 Microsoft Corporation
**********************************************************************
[vcvarsall.bat] Environment initialized for: 'x64'
Configuring build for Qt "6.2.4".
Configuring Qt to build in -release configuration.
Configuring Qt to deploy to "C:\Qt.2.4\release\bin".
QT_LLVM_CLANG_DIR is "C:\Qt\llvm-develop-install\release".
+ cd qtbase
+ C:\Qt.2.4\source\qtbase\configure.bat -top-level -prefix "C:\Qt.2.4\release\bin" -release -feature-clang -feature-clangcpp -- -D LLVM_INSTALL_DIR="C:\Qt\llvm-develop-install\release"
-- Windows 10 SDK version: 10.0.22621.0
'C:/Program Files/CMake/bin/cmake.exe' '-D' 'LLVM_INSTALL_DIR=C:\\Qt\\llvm-develop-install\\release' '-DCMAKE_INSTALL_PREFIX=C://Qt//6.2.4//release//bin' '-DCMAKE_BUILD_TYPE=Release' '-DINPUT_clang=yes' '-DINPUT_clangcpp=yes' '-G' 'Ninja' 'C:/Qt/6.2.4/source'
-- The CXX compiler identification is MSVC 19.36.32535.0
-- The C compiler identification is MSVC 19.36.32535.0
-- The ASM compiler identification is MSVC
-- Found assembler: C:/Program Files/Microsoft Visual Studio/2022/Community/VC/Tools/MSVC/14.36.32532/bin/Hostx64/x64/cl.exe
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: C:/Program Files/Microsoft Visual Studio/2022/Community/VC/Tools/MSVC/14.36.32532/bin/Hostx64/x64/cl.exe - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: C:/Program Files/Microsoft Visual Studio/2022/Community/VC/Tools/MSVC/14.36.32532/bin/Hostx64/x64/cl.exe - skipped
-- Detecting C compile features
-- Detecting C compile features - done

I have no idea why the way I was doing it was not working.  My guess is something to do with the terminal environment.

huangapple
  • 本文由 发表于 2023年6月29日 07:16:28
  • 转载请务必保留本文链接:https://go.coder-hub.com/76577226.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定