Gitlab pipeline on Windows with MSVC. Unable to compile Qt App
-
wrote on 17 Apr 2023, 13:29 last edited by
Hi!
I have a problem setting up gitlab pipeline with Windows10 runner. I was thinking to put one of my project to Ci/CD and try learn some Devops ;) But I'm linux developer and setting up windows environment is giving me some hard time...
So... I'm trying to compile Qt Application using 6.4.3 version with cmake, and MSVC tools. This is my config for the pipeline:
variables: GIT_SUBMODULE_STRATEGY: none compile: tags: - mcs_win10 stage: build before_script: - - $env:Path += ';C:\Qt\6.4.3\msvc2019_64\bin;C:\Qt\Tools\Ninja\' - git config -l --show-origin --show-scope - git config --global user.email "grzes_rezmer@o2.pl" - git config --global user.name "Grzegorz Rezmer" - git ls-remote https://gitlab-ci-token:${CI_JOB_TOKEN}@gitlab.com/GoRo3/mcs-licancekey-controller.git - git config --global url."https://gitlab-ci-token:${CI_JOB_TOKEN}@gitlab.com/GoRo3/mcs-licancekey-controller.git".insteadOf git@gitlab.com:GoRo3/mcs-licancekey-controller.git - git submodule update --init script: - CMD.EXE - C:/Qt/6.4.3/msvc2019_64/bin/qtenv2.bat - C:/"Program Files"/"Microsoft Visual Studio"/2022/Community/VC/Auxiliary/Build/vcvarsall.bat x86_amd64 - C:/Qt/Tools/CMake_64/bin/cmake.exe -S . -B build -GNinja -DCMAKE_BUILD_TYPE:STRING=Release - C:/Qt/Tools/CMake_64/bin/cmake.exe --build build cache: paths: - "build"
And unfortunately, pipeline fails with:
C:/Qt/Tools/CMake_64/bin/cmake.exe -S . -B build -GNinja -DCMAKE_BUILD_TYPE:STRING=Release -- The CXX compiler identification is unknown CMake Error at CMakeLists.txt:3 (project): No CMAKE_CXX_COMPILER could be found. Tell CMake where to find the compiler by setting either the environment variable "CXX" or the CMake cache entry CMAKE_CXX_COMPILER to the full path to the compiler, or to the compiler name if it is in the PATH. -- Configuring incomplete, errors occurred! See also "C:/GitLab-Runner/builds/dzmQKq2o/0/GoRo3/mcs_manager/build/CMakeFiles/CMakeOutput.log". See also "C:/GitLab-Runner/builds/dzmQKq2o/0/GoRo3/mcs_manager/build/CMakeFiles/CMakeError.log". Cleaning up project directory and file based variables 00:01 ERROR: Job failed: exit status 1
When I reproduce these steps on the runner machine in the cmd prompt it works fine and CMake can find all libraries and compilers. I have fought with it all weekend and have no clue what is wrong.
Looking forward to some help!
Best Regards!
-
Hi!
I have a problem setting up gitlab pipeline with Windows10 runner. I was thinking to put one of my project to Ci/CD and try learn some Devops ;) But I'm linux developer and setting up windows environment is giving me some hard time...
So... I'm trying to compile Qt Application using 6.4.3 version with cmake, and MSVC tools. This is my config for the pipeline:
variables: GIT_SUBMODULE_STRATEGY: none compile: tags: - mcs_win10 stage: build before_script: - - $env:Path += ';C:\Qt\6.4.3\msvc2019_64\bin;C:\Qt\Tools\Ninja\' - git config -l --show-origin --show-scope - git config --global user.email "grzes_rezmer@o2.pl" - git config --global user.name "Grzegorz Rezmer" - git ls-remote https://gitlab-ci-token:${CI_JOB_TOKEN}@gitlab.com/GoRo3/mcs-licancekey-controller.git - git config --global url."https://gitlab-ci-token:${CI_JOB_TOKEN}@gitlab.com/GoRo3/mcs-licancekey-controller.git".insteadOf git@gitlab.com:GoRo3/mcs-licancekey-controller.git - git submodule update --init script: - CMD.EXE - C:/Qt/6.4.3/msvc2019_64/bin/qtenv2.bat - C:/"Program Files"/"Microsoft Visual Studio"/2022/Community/VC/Auxiliary/Build/vcvarsall.bat x86_amd64 - C:/Qt/Tools/CMake_64/bin/cmake.exe -S . -B build -GNinja -DCMAKE_BUILD_TYPE:STRING=Release - C:/Qt/Tools/CMake_64/bin/cmake.exe --build build cache: paths: - "build"
And unfortunately, pipeline fails with:
C:/Qt/Tools/CMake_64/bin/cmake.exe -S . -B build -GNinja -DCMAKE_BUILD_TYPE:STRING=Release -- The CXX compiler identification is unknown CMake Error at CMakeLists.txt:3 (project): No CMAKE_CXX_COMPILER could be found. Tell CMake where to find the compiler by setting either the environment variable "CXX" or the CMake cache entry CMAKE_CXX_COMPILER to the full path to the compiler, or to the compiler name if it is in the PATH. -- Configuring incomplete, errors occurred! See also "C:/GitLab-Runner/builds/dzmQKq2o/0/GoRo3/mcs_manager/build/CMakeFiles/CMakeOutput.log". See also "C:/GitLab-Runner/builds/dzmQKq2o/0/GoRo3/mcs_manager/build/CMakeFiles/CMakeError.log". Cleaning up project directory and file based variables 00:01 ERROR: Job failed: exit status 1
When I reproduce these steps on the runner machine in the cmd prompt it works fine and CMake can find all libraries and compilers. I have fought with it all weekend and have no clue what is wrong.
Looking forward to some help!
Best Regards!
wrote on 17 Apr 2023, 23:45 last edited byHi @GoRo3,
It would help to provide the full log. In particular, the output of this line:
C:/"Program Files"/"Microsoft Visual Studio"/2022/Community/VC/Auxiliary/Build/vcvarsall.bat x86_amd64
Also, dump out the
CXX
environment variable before running cmake, just to see what its set to. Something like:- echo "%CXX%"
Cheers.
-
Hi @GoRo3,
It would help to provide the full log. In particular, the output of this line:
C:/"Program Files"/"Microsoft Visual Studio"/2022/Community/VC/Auxiliary/Build/vcvarsall.bat x86_amd64
Also, dump out the
CXX
environment variable before running cmake, just to see what its set to. Something like:- echo "%CXX%"
Cheers.
wrote on 18 Apr 2023, 06:49 last edited byI have made small changes in script:
before_script: # Install necessary packages - - $env:Path += ';C:\Qt\6.4.3\msvc2019_64\bin;C:\Qt\Tools\Ninja\;C:\Qt\6.4.3\msvc2019_64;%QT_INSTALL_DIR%' - echo $env:Path - 'dir env:' - git config --global user.email "grzes_rezmer@o2.pl" - git config --global user.name "Grzegorz Rezmer" - git ls-remote https://gitlab-ci-token:${CI_JOB_TOKEN}@gitlab.com/GoRo3/mcs-licancekey-controller.git - git config --global url."https://gitlab-ci-token:${CI_JOB_TOKEN}@gitlab.com/GoRo3/mcs-licancekey-controller.git".insteadOf git@gitlab.com:GoRo3/mcs-licancekey-controller.git - git submodule update --init - "& \"C:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\VC\\Auxiliary\\Build\\vcvarsall.bat\" x64" - 'dir env:' setup: extends: - .shared_windows_runners stage: setup script: # Print installed Qt version - qmake -v # Set up build directory - mkdir build - cd build # Configure CMake with Ninja - cmake .. -G Ninja -DCMAKE_PREFIX_PATH='C:\\Qt\\6.4.3\\msvc2019_64'
And here is the output:
$ $env:Path += ';C:\Qt\6.4.3\msvc2019_64\bin;C:\Qt\Tools\Ninja\;C:\Qt\6.4.3\msvc2019_64;$QT_INSTALL_DIR' $ echo $env:Path C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Windows\System32\OpenSSH\;C:\Program Files (x86)\Git\cmd;C:\Program Files\CMake\bin;C:\Users\grzes\AppData\Local\Microsoft\WindowsApps;C:\Program Files\Oracle\VirtualBox;C:\Program Files (x86)\Oracle\VirtualBox;C:\Qt\6.4.3\msvc2019_64\bin;C:\Qt\Tools\Ninja\;C:\Qt\6.4.3\msvc2019_64;$QT_INSTALL_DIR $ & "C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Auxiliary\Build\vcvarsall.bat" x64 ********************************************************************** ** Visual Studio 2022 Developer Command Prompt v17.3.6 ** Copyright (c) 2022 Microsoft Corporation ********************************************************************** [vcvarsall.bat] Environment initialized for: 'x64' $ dir env: ALLUSERSPROFILE C:\ProgramData APPDATA C:\Users\grzes\AppData\Roaming CI_RUNNER_DESCRIPTION local_windows10 CI_RUNNER_EXECUTABLE_ARCH windows/amd64 CI_RUNNER_ID 22712331 CI_RUNNER_REVISION dcfb4b66 CI_RUNNER_SHORT_TOKEN dzmQKq2o CI_RUNNER_TAGS ["mcs_win10"] CI_RUNNER_VERSION 15.10.1 CI_SERVER yes CI_SERVER_HOST gitlab.com CI_SERVER_NAME GitLab CI_SERVER_PORT 443 CI_SERVER_PROTOCOL https CI_SERVER_REVISION 619f6b13697 CI_SERVER_SHELL_SSH_HOST gitlab.com CI_SERVER_SHELL_SSH_PORT 22 CI_SERVER_URL https://gitlab.com CI_SERVER_VERSION 15.11.0-pre CI_SERVER_VERSION_MAJOR 15 CI_SERVER_VERSION_MINOR 11 CI_SERVER_VERSION_PATCH 0 CI_SHARED_ENVIRONMENT true CI_TEMPLATE_REGISTRY_HOST registry.gitlab.com CommonProgramFiles C:\Program Files\Common Files CommonProgramFiles(x86) C:\Program Files (x86)\Common Files CommonProgramW6432 C:\Program Files\Common Files COMPUTERNAME DESKTOP-NCBVT06 ComSpec C:\Windows\system32\cmd.exe CONFIG_FILE C:\GitLab-Runner\config.toml DriverData C:\Windows\System32\Drivers\DriverData FF_CMD_DISABLE_DELAYED_ERRO... false FF_DISABLE_POWERSHELL_STDIN false FF_DISABLE_UMASK_FOR_DOCKER... false FF_ENABLE_BASH_EXIT_CODE_CHECK false FF_ENABLE_JOB_CLEANUP false FF_KUBERNETES_HONOR_ENTRYPOINT false FF_NETWORK_PER_BUILD false FF_POSIXLY_CORRECT_ESCAPES false FF_RESOLVE_FULL_TLS_CHAIN true FF_SCRIPT_SECTIONS false FF_SET_PERMISSIONS_BEFORE_C... true FF_SKIP_NOOP_BUILD_STAGES true FF_USE_ADVANCED_POD_SPEC_CO... false FF_USE_DIRECT_DOWNLOAD true FF_USE_DYNAMIC_TRACE_FORCE_... false FF_USE_FASTZIP false FF_USE_IMPROVED_URL_MASKING false FF_USE_LEGACY_KUBERNETES_EX... false FF_USE_NEW_BASH_EVAL_STRATEGY false FF_USE_NEW_SHELL_ESCAPE false FF_USE_POD_ACTIVE_DEADLINE_... false FF_USE_POWERSHELL_PATH_RESO... false FF_USE_WINDOWS_LEGACY_PROCE... true HOMEDRIVE C: HOMEPATH \Users\grzes LOCALAPPDATA C:\Users\grzes\AppData\Local OS Windows_NT Path C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPo... PATHEXT .COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC;.CPL PROCESSOR_ARCHITECTURE AMD64 PROCESSOR_IDENTIFIER Intel64 Family 6 Model 44 Stepping 1, GenuineIntel PROCESSOR_LEVEL 6 PROCESSOR_REVISION 2c01 ProgramData C:\ProgramData ProgramFiles C:\Program Files ProgramFiles(x86) C:\Program Files (x86) ProgramW6432 C:\Program Files PSExecutionPolicyPreference Bypass PSModulePath C:\Users\grzes\Documents\WindowsPowerShell\Modules;C:\Program Files\WindowsPowerShell... PUBLIC C:\Users\Public QT_INSTALL_DIR C:\\Qt\\6.4.3\\msvc2019_64 RUNNER_TEMP_PROJECT_DIR C:\GitLab-Runner\builds\dzmQKq2o\0\GoRo3\mcs_manager.tmp SystemDrive C: SystemRoot C:\Windows USERDOMAIN DESKTOP-NCBVT06 USERDOMAIN_ROAMINGPROFILE DESKTOP-NCBVT06 windir C:\Windows $ qmake -v QMake version 3.1 Using Qt version 6.4.3 in C:/Qt/6.4.3/msvc2019_64/lib $ mkdir build PSPath : Microsoft.PowerShell.Core\FileSystem::C:\GitLab-Runner\builds\dzmQKq2o\0\GoRo3\mcs_manager\build PSParentPath : Microsoft.PowerShell.Core\FileSystem::C:\GitLab-Runner\builds\dzmQKq2o\0\GoRo3\mcs_manager PSChildName : build PSDrive : C PSProvider : Microsoft.PowerShell.Core\FileSystem PSIsContainer : True Name : build FullName : C:\GitLab-Runner\builds\dzmQKq2o\0\GoRo3\mcs_manager\build Parent : mcs_manager Exists : True Root : C:\ Extension : CreationTime : 18.04.2023 08:39:06 CreationTimeUtc : 18.04.2023 06:39:06 LastAccessTime : 18.04.2023 08:39:06 LastAccessTimeUtc : 18.04.2023 06:39:06 LastWriteTime : 18.04.2023 08:39:06 LastWriteTimeUtc : 18.04.2023 06:39:06 Attributes : Directory Mode : d----- BaseName : build Target : {} LinkType : $ cd build $ cmake .. -G Ninja -DCMAKE_PREFIX_PATH="$QT_INSTALL_DIR" -- The CXX compiler identification is unknown CMake Error at CMakeLists.txt:3 (project): No CMAKE_CXX_COMPILER could be found. Tell CMake where to find the compiler by setting either the environment variable "CXX" or the CMake cache entry CMAKE_CXX_COMPILER to the full path to the compiler, or to the compiler name if it is in the PATH. -- Configuring incomplete, errors occurred! Cleaning up project directory and file based variables ERROR: Job failed: exit status 1
It seams that CXX is not set.
-
wrote on 18 Apr 2023, 08:30 last edited by
Hmm. Well,
vcvarsall.bat
should have done all cmake wants :shrug:You can always just go ahead and set
CMAKE_CXX_COMPILER
to the path to the compiler, ie something like:cmake ... -DCMAKE_CXX_COMPILER="C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Bin\cl.exe" ...
BTW, what does the
&
at the start of this line do? (just curious)- "& \"C:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\VC\\Auxiliary\\Build\\vcvarsall.bat\" x64"
Cheers.
-
Hmm. Well,
vcvarsall.bat
should have done all cmake wants :shrug:You can always just go ahead and set
CMAKE_CXX_COMPILER
to the path to the compiler, ie something like:cmake ... -DCMAKE_CXX_COMPILER="C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Bin\cl.exe" ...
BTW, what does the
&
at the start of this line do? (just curious)- "& \"C:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\VC\\Auxiliary\\Build\\vcvarsall.bat\" x64"
Cheers.
wrote on 18 Apr 2023, 10:33 last edited by cristian-adamThis post is deleted! -
wrote on 18 Apr 2023, 10:56 last edited by
CMake will look into the
PATH
environment variable in order to search for C/C++ compilers.With the
CXX
andCC
environment variables you can tell CMake which compiler names you are interested in. In the case that you have more compilers inPATH
.The
"C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Auxiliary\Build\vcvars64.bat"
batch file will set some environment variables that are needed by thecl.exe
compiler:PATH
INCLUDE
LIB
In your setup the environment variables get cleared and CMake doesn't have access to them.
In my case I have:
PATH=Path=C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.35.32215\bin\HostX64\x64;%PATH%
INCLUDE=C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.35.32215\include;C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.35.32215\ATLMFC\include;C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Auxiliary\VS\include;C:\Program Files (x86)\Windows Kits\10\include\10.0.22000.0\ucrt;C:\Program Files (x86)\Windows Kits\10\\include\10.0.22000.0\\um;C:\Program Files (x86)\Windows Kits\10\\include\10.0.22000.0\\shared;C:\Program Files (x86)\Windows Kits\10\\include\10.0.22000.0\\winrt;C:\Program Files (x86)\Windows Kits\10\\include\10.0.22000.0\\cppwinrt;C:\Program Files (x86)\Windows Kits\NETFXSDK\4.8\include\um
LIB=C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.35.32215\ATLMFC\lib\x64;C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.35.32215\lib\x64;C:\Program Files (x86)\Windows Kits\NETFXSDK\4.8\lib\um\x64;C:\Program Files (x86)\Windows Kits\10\lib\10.0.22000.0\ucrt\x64;C:\Program Files (x86)\Windows Kits\10\\lib\10.0.22000.0\\um\x64
If you want to make sure that these environment variables are available to CMake you can have a
msvc-env.cmake
file with:set(ENV{CXX} "cl.exe") set(ENV{CC} "cl.exe") set(ENV{PATH} "path values") set(ENV{LIB} "lib values") set(ENV{INCLUDE} "include values")
Make sure you replace all backslashes
\
with forwared slashes/
.And give this to CMake when you configure your project as:
cmake.exe -S . -B build -GNinja -DCMAKE_BUILD_TYPE:STRING=Release -C msvc-env.cmake
This way you don't need to fiddle around with
vcvarsall.bat
or what not. But you have to make sure that all version numbers are valid.I have an example using CMake Presets at https://www.qt.io/blog/qt-creator-9-cmakepresets
1/6