Qt compiled program prompt cannot find libxxx.dll

148 Views
No Comments

A total of 628 characters, expected to take 2 minutes to complete reading.

Reason

Qt 编译的程序提示找不到 libxxx.dll

出现这个问题是因为找不到动态库,要用命令 windeployqt 来部署动态库。

Solution

更完整的方法可见:https://www.mcso.top/computer/programming/clion-qt-program/

Method 1: Manually add

Qt 编译的程序提示找不到 libxxx.dll

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

Qt 编译的程序提示找不到 libxxx.dll

Then many other files are generated in the build directory, and then the run becomes:

Qt 编译的程序提示找不到 libxxx.dll

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!"
)

Qt 编译的程序提示找不到 libxxx.dll

Then rebuild it:

Qt 编译的程序提示找不到 libxxx.dll

The result is still the same, can run:

Qt 编译的程序提示找不到 libxxx.dll

END
 0
Comment(No Comments)
验证码
en_USEnglish
Article Directory