使用CMAKE / CPACK / NSIS64安装的程序找不到QT插件

发布于 2025-01-24 17:13:08 字数 1682 浏览 0 评论 0原文

我正在尝试使用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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文