Program installed with CMake /CPack / NSIS64 cannot find Qt plugins

288 views Asked by At

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.

0

There are 0 answers