A total of 628 characters, expected to take 2 minutes to complete reading.
Reason
出现这个问题是因为找不到动态库,要用命令 windeployqt
来部署动态库。
Solution
更完整的方法可见:https://www.mcso.top/computer/programming/clion-qt-program/
Method 1: Manually add
This is because there is no use of Qt's Dynamic Link Library . We find QT directory \QT version number \mingw_64\bin directory, for example in my this is QT\6.7.0\mingw_64\bin, enter and create here. cmd window , enter:
# 加载环境
qtenv2.bat
# 动态链接库
windeployqt 你的文件.exe
Then many other files are generated in the build directory, and then the run becomes:
Method 2: Modify CMakeLists.txt
In CMakeLists.txt Add the following code, will 3DSystemHelper
Modify the name of the executable generated for you:
add_custom_command(TARGET 3DSystemHelper POST_BUILD
COMMAND ${CMAKE_COMMAND} -E echo "Start deploy Qt..."
COMMAND ${CMAKE_PREFIX_PATH}/bin/qtenv2.bat
COMMAND windeployqt ${EXECUTABLE_OUTPUT_PATH}/3DSystemHelper.exe
COMMAND ${CMAKE_COMMAND} -E echo "Deploy Qt completed!"
)
Then rebuild it:
The result is still the same, can run: