Qt windeployqt编译报错Unable to find the platform plugin.
使用Clion CMake编译Qt项目,编译完成,生成EXE后发现不能运行,报:
This application failed to start because it could not find or load the Qt platform plugin "windows"in "". Reinstalling the application may fix this problem.
网上查资料说是exe文件少Qt必要的库,进入目录发现确实,生成后就只有一个exe,没有QT相关动态库.
通过windeployqt qtGUIDemo.exe,报错:
D:\work\C++\C++\qtGUIDemo\cmake-build-debug\qtGUIDemo.exe 64 bit, debug executable Direct dependencies: Qt5Core Qt5Widgets All dependencies : Qt5Core Qt5Gui Qt5Widgets To be deployed : Qt5Core Qt5Gui Qt5Widgets Unable to find the platform plugin.
查资料发现很多说是MinGW的BUG,但是我是用的MSVC编译器.
后来发现是CMake toolchain(工具链) 没有选择VisualStudio.
默认是:
需要选择Visual Studio(这个名字是我配置VS时的名字):
Toolchain处的Visual Studio 是在Clion 配置VS时的名字,Clion 配置VS请自行百度:
配置好后,发现运行位置名称也添加了 - Visual Studio:
重新编译项目, 在使用windeployqt qtGUIDemo.exe(exe文件名), 成功导出相关库文件。