Browse Source

add `-rpath` via qmake as needed

* For https://github.com/mavlink/qgroundcontrol/pull/9947

this solves libairmap and most of the qt libraries. but note some defects still exist:

```
$ ./QGroundControl
QML debugging is enabled. Only use this in a safe environment.
qt.qpa.plugin: Could not find the Qt platform plugin "xcb" in ""
This application failed to start because no Qt platform plugin could be initialized. Reinstalling the application may fix this problem.
```
The above error is solved with `QT_PLUGIN_PATH=./Qt/plugins`.

After that, the below error message shows up:
```
$ ./QGroundControl
QML debugging is enabled. Only use this in a safe environment.
./QGroundControl: symbol lookup error: /lib/x86_64-linux-gnu/libQt5XcbQpa.so.5: undefined symbol: _ZN22QWindowSystemInterface24setPlatformFiltersEventsEb, version Qt_5_PRIVATE_API
```
Setting `LD_LIBRARY_PATH=./Qt/libs` appears to solve that one.

It looks like some of the Qt libraries need to be configured? I spent a half hour looking at that and didn't find a quick/easy solution.

* QT_PLUGIN_PATH might be solved with `QCoreApplication::addLibraryPath()` set to `QCoreApplication::applicationDirPath() / "Qt/libs"`, but I'm not 100% sure if it needs to be platform specific.
* I'm not sure which library is trying to poke at `libQt5XcbQpa` or how to solve that at runtime.

Both of the environment variables can be avoided by using `qt.conf` in the same directory:
```
$ cat <<EOF | tee qt.conf
[Paths]
Prefix=./
Libraryes=Qt/libs
Plugins=Qt/plugins
EOF
$ ./QGroundControl
QML debugging is enabled. Only use this in a safe environment.
./QGroundControl: symbol lookup error: /lib/x86_64-linux-gnu/libQt5XcbQpa.so.5: undefined symbol: _ZN22QWindowSystemInterface24setPlatformFiltersEventsEb, version Qt_5_PRIVATE_API
```

which reaches us to the same undefined symbol error pointing to a system-installed Qt-5 library...

A little bit of a rabbit hole suggests that `patchelf` can solve our problem:

```
$ ldd ./Qt/plugins/platforms/libqxcb.so | grep -i libQt
./Qt/plugins/platforms/libqxcb.so: /lib/x86_64-linux-gnu/libQt5Core.so.5: version `Qt_5.15' not found (required by ./Qt/plugins/platforms/libqxcb.so)
        libQt5XcbQpa.so.5 => /lib/x86_64-linux-gnu/libQt5XcbQpa.so.5 (0x00007f8c6ad23000)
        libQt5Gui.so.5 => /lib/x86_64-linux-gnu/libQt5Gui.so.5 (0x00007f8c6a616000)
        libQt5DBus.so.5 => /lib/x86_64-linux-gnu/libQt5DBus.so.5 (0x00007f8c6a57a000)
        libQt5Core.so.5 => /lib/x86_64-linux-gnu/libQt5Core.so.5 (0x00007f8c6a02f000)
$ patchelf --set-rpath \$ORIGIN/../../libs ./Qt/plugins/platforms/libqxcb.so
$ ldd staging/Qt/plugins/platforms/libqxcb.so | grep -i libQt
        libQt5XcbQpa.so.5 => /home/kbennett/src/public/qgroundcontrol/build/build-qgroundcontrol-Desktop_Qt_5_15_2_GCC_64bit-Debug/staging/Qt/plugins/platforms/../../libs/libQt5XcbQpa.so.5 (0x00007fceceef1000)
        libQt5Gui.so.5 => /home/kbennett/src/public/qgroundcontrol/build/build-qgroundcontrol-Desktop_Qt_5_15_2_GCC_64bit-Debug/staging/Qt/plugins/platforms/../../libs/libQt5Gui.so.5 (0x00007fcece479000)
        libQt5DBus.so.5 => /home/kbennett/src/public/qgroundcontrol/build/build-qgroundcontrol-Desktop_Qt_5_15_2_GCC_64bit-Debug/staging/Qt/plugins/platforms/../../libs/libQt5DBus.so.5 (0x00007fcece1eb000)
        libQt5Core.so.5 => /home/kbennett/src/public/qgroundcontrol/build/build-qgroundcontrol-Desktop_Qt_5_15_2_GCC_64bit-Debug/staging/Qt/plugins/platforms/../../libs/libQt5Core.so.5 (0x00007fcecd9f5000)
```

However, `patchelf` is not available on all systems...
QGC4.4
Keith Bennett 4 years ago committed by Don Gagne
parent
commit
70651e3689
  1. 1
      QGCPostLinkCommon.pri

1
QGCPostLinkCommon.pri

@ -73,6 +73,7 @@ WindowsBuild { @@ -73,6 +73,7 @@ WindowsBuild {
LinuxBuild {
QMAKE_POST_LINK += && mkdir -p $$DESTDIR/Qt/libs && mkdir -p $$DESTDIR/Qt/plugins
QMAKE_RPATHDIR += $ORIGIN/Qt/libs
# QT_INSTALL_LIBS
QT_LIB_LIST += \

Loading…
Cancel
Save