使用CMAKE / CPACK / NSIS64安装的程序找不到QT插件
我正在尝试使用CMAKE安装C ++/QT/QML程序。我尝试了ifw
生成器,但是我宁愿坚持nsis64
。 设置安装文件已正确生成,并且程序已正确安装。但是我的安装QT程序立即崩溃,因为
qt.qpa.plugin: Could not find the Qt platform plugin "windows" in ""
从命令行运行程序时很容易解决问题:我们只需要将qt_qpa_platform_plugin_path_path
设置为当前目录> qwindows.dll 那里)。
奇怪的是,.exe
没有查看QT插件的当前程序目录。无论如何,解决我的问题的一种方法是:如何在快捷方式.lnk (由NSIS创建)中设置环境变量?
我尝试了使用NSIS的一堆事情(添加在nsis.template.in
中):
CreateShortCut "$SMPROGRAMS\$STARTMENU_FOLDER\@[email protected]" "QT_QPA_PLATFORM_PLUGING_PATH=$INSTDIR\bin $INSTDIR\bin\@[email protected]"
CreateShortCut "$SMPROGRAMS\$STARTMENU_FOLDER\@CPACK_NSIS_DISPLAY_NAME@_cmd.lnk" \
"C:\Windows\System32\cmd.exe" "/c SET QT_QPA_PLATFORM_PLUGING_PATH=$INSTDIR\bin && start $INSTDIR\bin\@[email protected]"
但这不是编译。 也许有另一种实现这一目标的方法。即使有效,我也想避免在安装期间全球设置QT_QPA_PLATFORM_PLUGING_PATH_PATH
(如果可能),并将其限制为程序启动。
注意:文档说:
createShortCut“ $ smprograms \我的公司\我的program.lnk”“ $ instdir \ my program.exe”
“某些命令行参数”“ $ instdir \ my program.exe” 2 sw_shownormal
alt |控制| shift | f5“描述”
,但我不太确定如何在我的情况下使用它。
I am trying to install a C++/Qt/Qml program with CMake. I tried the IFW
generator, but I'd rather stick to NSIS64
.
Setup install file is correctly generated, and program is correctly installed. But my installed Qt program crashes right away, because
qt.qpa.plugin: Could not find the Qt platform plugin "windows" in ""
It is an easy to solve problem when running the program from the command line: we just need to set QT_QPA_PLATFORM_PLUGIN_PATH
to the current directory (I installed/copied qwindows.dll
there).
It is strange that the .exe
does not look into the current program directory for Qt plugins. Anyways, a way to solve my problem would be: how to set an environment variable in a shortcut .lnk (created by NSIS)?
I have tried a bunch of things with NSIS (added in NSIS.template.in
):
CreateShortCut "$SMPROGRAMS\$STARTMENU_FOLDER\@[email protected]" "QT_QPA_PLATFORM_PLUGING_PATH=$INSTDIR\bin $INSTDIR\bin\@[email protected]"
CreateShortCut "$SMPROGRAMS\$STARTMENU_FOLDER\@CPACK_NSIS_DISPLAY_NAME@_cmd.lnk" \
"C:\Windows\System32\cmd.exe" "/c SET QT_QPA_PLATFORM_PLUGING_PATH=$INSTDIR\bin && start $INSTDIR\bin\@[email protected]"
but this does not compile.
Maybe there is a different way to achieve this. Even if that would work, I would like to avoid setting QT_QPA_PLATFORM_PLUGING_PATH
globally during the install, if possible, and restrain it to the program launch.
NOTE: documentation says:
CreateShortcut "$SMPROGRAMS\My Company\My Program.lnk" "$INSTDIR\My Program.exe"
"some command line parameters" "$INSTDIR\My Program.exe" 2 SW_SHOWNORMAL
ALT|CONTROL|SHIFT|F5 "a description"
but I am not too sure about how to use this in my case.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论