0

I have a project and I need to prepare a CMakeLists.txt file for it. I also have tests which I need to get an executables for after building the project.

Tests are located in a separate backEndTest folder with their own CMakeLists.txt file. In order to achieve that I decided to use qtwindeploy tool for that. However, when I compile everything and try to run backEndText.exe file I have errors related to missing dlls.

That's what my main CMakeLists.txt file looks like:

add_subdirectory(backEndTest)

find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Test)
find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Test)

set(QtBinDir "C:/Qt/6.2.3/mingw_64/bin")

set(winDeploy "${QtBinDir}/windeployqt.exe")

set(backEndTest ${CMAKE_BINARY_DIR}/backEndTest/backEndTest.exe)

set(testBackEnd TRUE)

if (testBackEnd)
    execute_process(COMMAND ${winDeploy} ${backEndTest} --compiler-runtime )
endif()

Do you have any idea why dlls are not getting linked?

Tsyvarev
  • 60,011
  • 17
  • 110
  • 153
CuriousPan
  • 783
  • 1
  • 8
  • 14
  • Your title says that "dlls are not **loaded**". Your last sentence tells "why dlls are not getting **linked**". So whether you got error at the **linking** stage, or when try to **run** the test? These are different problems. – Tsyvarev Jun 29 '22 at 13:31
  • @Tsyvarev, sorry I might didn't write in a proper way due to lack of knowledge and experience. When I run the .exe file, I got errors. – CuriousPan Jun 29 '22 at 13:37
  • @absolute.madness, well, I assume `set(QtBinDir "C:/Qt/6.2.3/mingw_64/bin")` should do the trick. – CuriousPan Jun 29 '22 at 13:45
  • @absolute.madness, I run the mentioned `backEndTest.exe` from the build folder by double-clicking the mouse. The missing dlls are: `Qt6Core.dll`, `Qt6Test.dll` and `libgcc_s_seh-1.dll`. – CuriousPan Jun 29 '22 at 14:31
  • As for the question why `execute_process(COMMAND ${winDeploy} ${backEndTest} --compiler-runtime )` doesn't work - no idea so far. You could try to run it manually and check if it works as expected. I initially missed that and misunderstood the question, which makes my previous comments somewhat irrelevant probably. – absolute.madness Jun 29 '22 at 15:56
  • @CuriousPanCake The only thing I notice is that options usually go before files, like: `execute_process(COMMAND ${winDeploy} --compiler-runtime ${backEndTest} )` - perhaps it returns an error? Also make sure the path doesn't contain space, otherwise they should be escaped by quotation marks. I don't have a windows machine at my disposal atm to check. – absolute.madness Jun 29 '22 at 16:05
  • `windeployqt.exe` should copy dll-s into the folder with your test executable. Are that dlls are actually existed in that folder? – Tsyvarev Jun 29 '22 at 16:37
  • @Tsyvarev, yes they do. Actually, after talking to another person I realized that I need to write `windeployqt.exe` after building `backEndTest.exe`. Now I need to write some CMake command to do it. – CuriousPan Jun 29 '22 at 17:32

0 Answers0