You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

在Appveyor上编译带OpenSSL与QML WebView的Qt5.10静态应用遇阻

Let's tackle your two Appveyor + Qt issues one by one:

Issue 1: MSVC 2017 Compilation Error (Cannot find 'cl' compiler)

The error you're seeing happens because Appveyor's Visual Studio 2017 image doesn't automatically initialize the MSVC build environment—you need to explicitly set up the compiler paths and variables first. Additionally, your qmake spec and PATH configuration have small issues that are contributing to the problem.

Fixes to your .appveyor.yml:

  1. Initialize the MSVC 2017 64-bit build environment using vcvarsall.bat
  2. Use the correct qmake spec for MSVC 2017 64-bit (win32-msvc2017 instead of win32-msvc)
  3. Remove the MinGW path from your PATH (it's unnecessary when using MSVC and can cause conflicts)

Here's the corrected config:

image: Visual Studio 2017
branches:
  only:
    - master

install:
  # Initialize MSVC 2017 64-bit build environment
  - call "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Auxiliary\Build\vcvarsall.bat" x64
  # Set Qt 5.10.1 MSVC 2017 64-bit path
  - set QTDIR=C:\Qt\5.10.1\msvc2017_64
  # Update PATH to prioritize Qt's bin directory
  - set PATH=%QTDIR%\bin;%PATH%

build_script:
  # Run qmake with the correct MSVC 2017 spec
  - qmake app/QRegovar.pro -spec win32-msvc2017
  - qmake_all
  # Build with jom (faster than nmake for Qt projects)
  - C:\Qt\Tools\QtCreator\bin\jom.exe -f Makefile.Release

deploy:
  - provider: GitHub
    artifact: C:/projects/qregovar
    draft: true
    prerelease: false
    on:
      branch: master
      appveyor_repo_tag: true

Why this works:

  • The vcvarsall.bat x64 command sets up all the necessary environment variables for the 64-bit MSVC 2017 compiler, including adding cl.exe to your PATH.
  • Using win32-msvc2017 ensures qmake generates build files compatible with your MSVC 2017 installation.
  • Removing the MinGW path eliminates any potential conflicts between compiler tools.
Issue 2: Static Qt Builds on Appveyor & Creating Distributable Packages

By default, the Qt versions pre-installed on Appveyor are dynamically linked builds—they require accompanying Qt DLLs and QML modules to run. If you want a standalone package users can run without installing Qt, you have two solid options:

This is the fastest approach for most projects. Use Qt's windeployqt tool to collect all required dependencies, then package everything into an installer.

Add these steps to your .appveyor.yml after building:

after_build:
  # Create a directory for your deployable files
  - mkdir deploy
  # Copy your release executable to the deploy directory
  - copy app\release\QRegovar.exe deploy\
  # Run windeployqt to collect all dependencies (including QML modules)
  - windeployqt --qmldir app\qml deploy\QRegovar.exe
  # Optional: Install Inno Setup to create an installer
  - choco install innosetup
  # Build the installer using your Inno Setup script (replace with your script path)
  - iscc /O"deploy" app\installer\setup.iss

deploy:
  - provider: GitHub
    # Upload the installer instead of raw files
    artifact: deploy\QRegovarInstaller.exe
    draft: true
    prerelease: false
    on:
      branch: master
      appveyor_repo_tag: true

Option 2: Compile Static Qt on Appveyor

If you need a truly static executable (no external DLLs), you'll have to compile Qt from source with static linking enabled. This is slower, but possible with Appveyor's caching to speed up subsequent builds.

High-level steps:

  1. In the install phase, download Qt 5.10.1 source code
  2. Configure Qt with static build flags (e.g., -static, -release, -no-opengl, etc.)
  3. Compile Qt using jom
  4. Cache the compiled static Qt directory to avoid rebuilding every time
  5. Use this static Qt to build your project

Note: Static Qt builds require careful configuration (especially for QML and OpenSSL), and you'll need to ensure all dependencies (like OpenSSL) are also linked statically.


内容的提问来源于stack exchange,提问作者Ikit

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.28 07:25:21