Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Installation and Deployment
  4. Issues running an app using a custom library with Qt 6.9.1
Forum Updated to NodeBB v4.3 + New Features

Issues running an app using a custom library with Qt 6.9.1

Scheduled Pinned Locked Moved Unsolved Installation and Deployment
windows 11windeployqtcmakewebengine
3 Posts 2 Posters 122 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B Offline
    B Offline
    brinus
    wrote last edited by brinus
    #1

    Hi everyone,

    I'm currently developing a project on Windows 11 using Qt 6.9.1 (MSVC 2022) and CMake.
    The setup consists of two parts:

    1. MyLib: a library that defines some custom widgets, which also use QtWebEngine components (e.g. QWebEngineView, QWebChannel, …).
    2. MyExec: a GUI application (for Windows) that uses both Qt libraries and the custom widgets from MyLib.

    I successfully build and install MyLib using CMake, and I get the .lib and .dll files without any issues.

    However, I'm facing several problems when building and running MyExec:

    1. The only configuration that runs (without immediate startup errors) is when MyLib is built in Release and linked with MyExec also in Release. But in this case, the application crashes as soon as I open a panel that uses one of the custom widgets from MyLib.
    2. If I build MyLib and MyExec in Debug, the build succeeds, but when I run windeployqt.exe to deploy the required Qt libraries into the build folder, I get the following error:
    [build]   Checking C:/Qt/6.9.1/msvc2022_64/resources/icudtl.dat, C:/path/to/git/MyExec/build/Debug/resources/icudtl.dat
    [build]   icudtl.dat is up to date.
    [build]   Checking C:/Qt/6.9.1/msvc2022_64/resources/qtwebengine_devtools_resources.debug.pak, C:/path/to/git/MyExec/build/Debug/resources/qtwebengine_devtools_resources.debug.pak
    [build]   C:\Qt\6.9.1\msvc2022_64\resources\qtwebengine_devtools_resources.debug.pak does not exist.
    [build] C:\Program Files\Microsoft Visual Studio\2022\Professional\MSBuild\Microsoft\VC\v170\Microsoft.CppCommon.targets(166,5): error MSB3073: The command "setlocal [C:\path\to\git\MyExec\build\MyExec.vcxproj]
    [build] C:\Program Files\Microsoft Visual Studio\2022\Professional\MSBuild\Microsoft\VC\v170\Microsoft.CppCommon.targets(166,5): error MSB3073: "C:\Program Files\CMake\bin\cmake.exe" -E echo "Copying MyLib" [C:\path\to\git\MyExec\build\MyExec.vcxproj]
    [build] C:\Program Files\Microsoft Visual Studio\2022\Professional\MSBuild\Microsoft\VC\v170\Microsoft.CppCommon.targets(166,5): error MSB3073: if %errorlevel% neq 0 goto :cmEnd [C:\path\to\git\MyExec\build\MyExec.vcxproj]
    [build] C:\Program Files\Microsoft Visual Studio\2022\Professional\MSBuild\Microsoft\VC\v170\Microsoft.CppCommon.targets(166,5): error MSB3073: "C:\Program Files\CMake\bin\cmake.exe" -E copy_if_different C:\path\to\git\MyLib/install/bin/MyLibd.dll C:/path/to/git/MyExec/build/Debug [C:\path\to\git\MyExec\build\MyExec.vcxproj]
    [build] C:\Program Files\Microsoft Visual Studio\2022\Professional\MSBuild\Microsoft\VC\v170\Microsoft.CppCommon.targets(166,5): error MSB3073: if %errorlevel% neq 0 goto :cmEnd [C:\path\to\git\MyExec\build\MyExec.vcxproj]
    [build] C:\Program Files\Microsoft Visual Studio\2022\Professional\MSBuild\Microsoft\VC\v170\Microsoft.CppCommon.targets(166,5): error MSB3073: "C:\Program Files\CMake\bin\cmake.exe" -E echo "MyLib copied successfully" [C:\path\to\git\MyExec\build\MyExec.vcxproj]
    [build] C:\Program Files\Microsoft Visual Studio\2022\Professional\MSBuild\Microsoft\VC\v170\Microsoft.CppCommon.targets(166,5): error MSB3073: if %errorlevel% neq 0 goto :cmEnd [C:\path\to\git\MyExec\build\MyExec.vcxproj]
    [build] C:\Program Files\Microsoft Visual Studio\2022\Professional\MSBuild\Microsoft\VC\v170\Microsoft.CppCommon.targets(166,5): error MSB3073: :cmEnd [C:\path\to\git\MyExec\build\MyExec.vcxproj]
    [build] C:\Program Files\Microsoft Visual Studio\2022\Professional\MSBuild\Microsoft\VC\v170\Microsoft.CppCommon.targets(166,5): error MSB3073: endlocal & call :cmErrorLevel %errorlevel% & goto :cmDone [C:\path\to\git\MyExec\build\MyExec.vcxproj]
    [build] C:\Program Files\Microsoft Visual Studio\2022\Professional\MSBuild\Microsoft\VC\v170\Microsoft.CppCommon.targets(166,5): error MSB3073: :cmErrorLevel [C:\path\to\git\MyExec\build\MyExec.vcxproj]
    [build] C:\Program Files\Microsoft Visual Studio\2022\Professional\MSBuild\Microsoft\VC\v170\Microsoft.CppCommon.targets(166,5): error MSB3073: exit /b %1 [C:\path\to\git\MyExec\build\MyExec.vcxproj]
    [build] C:\Program Files\Microsoft Visual Studio\2022\Professional\MSBuild\Microsoft\VC\v170\Microsoft.CppCommon.targets(166,5): error MSB3073: :cmDone [C:\path\to\git\MyExec\build\MyExec.vcxproj]
    [build] C:\Program Files\Microsoft Visual Studio\2022\Professional\MSBuild\Microsoft\VC\v170\Microsoft.CppCommon.targets(166,5): error MSB3073: if %errorlevel% neq 0 goto :VCEnd [C:\path\to\git\MyExec\build\MyExec.vcxproj]
    [build] C:\Program Files\Microsoft Visual Studio\2022\Professional\MSBuild\Microsoft\VC\v170\Microsoft.CppCommon.targets(166,5): error MSB3073: setlocal [C:\path\to\git\MyExec\build\MyExec.vcxproj]
    [build] C:\Program Files\Microsoft Visual Studio\2022\Professional\MSBuild\Microsoft\VC\v170\Microsoft.CppCommon.targets(166,5): error MSB3073: "C:\Program Files\CMake\bin\cmake.exe" -E echo "Running windeployqt to deploy Qt dependencies" [C:\path\to\git\MyExec\build\MyExec.vcxproj]
    [build] C:\Program Files\Microsoft Visual Studio\2022\Professional\MSBuild\Microsoft\VC\v170\Microsoft.CppCommon.targets(166,5): error MSB3073: if %errorlevel% neq 0 goto :cmEnd [C:\path\to\git\MyExec\build\MyExec.vcxproj]
    [build] C:\Program Files\Microsoft Visual Studio\2022\Professional\MSBuild\Microsoft\VC\v170\Microsoft.CppCommon.targets(166,5): error MSB3073: "C:\Program Files\CMake\bin\cmake.exe" -E env QT_PLUGIN_PATH=C:\Qt\6.9.1\msvc2022_64/plugins C:\Qt\6.9.1\msvc2022_64/bin/windeployqt.exe --no-translations --verbose 2 --debug C:/path/to/git/MyExec/build/Debug [C:\path\to\git\MyExec\build\MyExec.vcxproj]
    [build] C:\Program Files\Microsoft Visual Studio\2022\Professional\MSBuild\Microsoft\VC\v170\Microsoft.CppCommon.targets(166,5): error MSB3073: if %errorlevel% neq 0 goto :cmEnd [C:\path\to\git\MyExec\build\MyExec.vcxproj]
    [build] C:\Program Files\Microsoft Visual Studio\2022\Professional\MSBuild\Microsoft\VC\v170\Microsoft.CppCommon.targets(166,5): error MSB3073: "C:\Program Files\CMake\bin\cmake.exe" -E echo "windeployqt completed successfully" [C:\path\to\git\MyExec\build\MyExec.vcxproj]
    [build] C:\Program Files\Microsoft Visual Studio\2022\Professional\MSBuild\Microsoft\VC\v170\Microsoft.CppCommon.targets(166,5): error MSB3073: if %errorlevel% neq 0 goto :cmEnd [C:\path\to\git\MyExec\build\MyExec.vcxproj]
    [build] C:\Program Files\Microsoft Visual Studio\2022\Professional\MSBuild\Microsoft\VC\v170\Microsoft.CppCommon.targets(166,5): error MSB3073: :cmEnd [C:\path\to\git\MyExec\build\MyExec.vcxproj]
    [build] C:\Program Files\Microsoft Visual Studio\2022\Professional\MSBuild\Microsoft\VC\v170\Microsoft.CppCommon.targets(166,5): error MSB3073: endlocal & call :cmErrorLevel %errorlevel% & goto :cmDone [C:\path\to\git\MyExec\build\MyExec.vcxproj]
    [build] C:\Program Files\Microsoft Visual Studio\2022\Professional\MSBuild\Microsoft\VC\v170\Microsoft.CppCommon.targets(166,5): error MSB3073: :cmErrorLevel [C:\path\to\git\MyExec\build\MyExec.vcxproj]
    [build] C:\Program Files\Microsoft Visual Studio\2022\Professional\MSBuild\Microsoft\VC\v170\Microsoft.CppCommon.targets(166,5): error MSB3073: exit /b %1 [C:\path\to\git\MyExec\build\MyExec.vcxproj]
    [build] C:\Program Files\Microsoft Visual Studio\2022\Professional\MSBuild\Microsoft\VC\v170\Microsoft.CppCommon.targets(166,5): error MSB3073: :cmDone [C:\path\to\git\MyExec\build\MyExec.vcxproj]
    [build] C:\Program Files\Microsoft Visual Studio\2022\Professional\MSBuild\Microsoft\VC\v170\Microsoft.CppCommon.targets(166,5): error MSB3073: if %errorlevel% neq 0 goto :VCEnd [C:\path\to\git\MyExec\build\MyExec.vcxproj]
    [build] C:\Program Files\Microsoft Visual Studio\2022\Professional\MSBuild\Microsoft\VC\v170\Microsoft.CppCommon.targets(166,5): error MSB3073: :VCEnd" exited with code 1. [C:\path\to\git\MyExec\build\MyExec.vcxproj]
    [proc] The command: "C:\Program Files\CMake\bin\cmake.EXE" --build c:/path/to/git/MyExec/build --config Debug --target MyExec -j 28 -- exited with code: 1
    [driver] Build completed: 00:00:14.862
    [build] Build finished with exit code 1
    

    I use CMake via the VS Code extension, the command it launches automatically is:

    [main] Building folder: c:/path/to/git/MyExec/build 
    [build] Starting build
    [proc] Executing command: "C:\Program Files\CMake\bin\cmake.EXE" --build c:/path/to/git/MyExec/build --config Debug --target MyExec -j 28 --
    [build] MSBuild version 17.13.9+e0f243f1e for .NET Framework
    

    In the CMakeLists.txt there are these lines of code:

    if (WIN32)
    
        add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD
            COMMAND ${CMAKE_COMMAND} -E echo "Copying MyLib"
            COMMAND ${CMAKE_COMMAND} -E copy_if_different $<$<CONFIG:Debug>:${MyLib_DLL_DEBUG}>$<$<CONFIG:Release>:${MyLib_DLL_RELEASE}> $<TARGET_FILE_DIR:${PROJECT_NAME}>
            COMMAND ${CMAKE_COMMAND} -E echo "MyLib copied successfully"
        )
    
        add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD
            COMMAND ${CMAKE_COMMAND} -E echo "Running windeployqt to deploy Qt dependencies"
            COMMAND ${CMAKE_COMMAND} -E env QT_PLUGIN_PATH=$ENV{QT6DIR}/plugins $ENV{QT6DIR}/bin/windeployqt.exe --no-translations --verbose 2 $<$<CONFIG:Debug>:--debug>$<$<CONFIG:Release>:--release> $<TARGET_FILE_DIR:${PROJECT_NAME}>
            COMMAND ${CMAKE_COMMAND} -E echo "windeployqt completed successfully"
        )
    endif()
    

    The error seems related to the missing file qtwebengine_devtools_resources.debug.pak, but I was unable to find any reference about it, even using the Qt Maintenance Tool.

    Any help would be appreciated :)

    1 Reply Last reply
    0
    • B Offline
      B Offline
      brinus
      wrote last edited by
      #2

      I've found a workaround and was able to make it go. I followd these steps:

      1. I forced the Qt libraries to be in Release mode, both in MyLib and in MyExec
      2. I forced the windeployqt to copy always Release configuration dependencies
      3. I forced the runtime library in MyLib and MyExec to be in release mode only
      1 Reply Last reply
      0
      • Christian EhrlicherC Offline
        Christian EhrlicherC Offline
        Christian Ehrlicher
        Lifetime Qt Champion
        wrote last edited by
        #3

        This is not a Qt problem but a general one with the msvc runtime - you must not mix different msvc runtimes (static, shared, debug, release)

        Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
        Visit the Qt Academy at https://academy.qt.io/catalog

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved