在Appveyor上编译带OpenSSL与QML WebView的Qt5.10静态应用遇阻
Let's tackle your two Appveyor + Qt issues one by one:
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:
- Initialize the MSVC 2017 64-bit build environment using
vcvarsall.bat - Use the correct qmake spec for MSVC 2017 64-bit (
win32-msvc2017instead ofwin32-msvc) - 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 x64command sets up all the necessary environment variables for the 64-bit MSVC 2017 compiler, including addingcl.exeto your PATH. - Using
win32-msvc2017ensures qmake generates build files compatible with your MSVC 2017 installation. - Removing the MinGW path eliminates any potential conflicts between compiler tools.
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:
Option 1: Dynamic Qt + windeployqt + Installer Tool (Recommended)
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:
- In the
installphase, download Qt 5.10.1 source code - Configure Qt with static build flags (e.g.,
-static,-release,-no-opengl, etc.) - Compile Qt using jom
- Cache the compiled static Qt directory to avoid rebuilding every time
- 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

