probonopd / go-appimage

Go implementation of AppImage tools
MIT License
813 stars 71 forks source link

Is there a way to specify a custom Qt directory? #221

Open yuriymacdev opened 2 years ago

yuriymacdev commented 2 years ago

On Ubuntu 20 the appimage tool picks up qt libs from the system library directory (/usr/lib/x86_64-linux-gnu/qt5) instead of the one used for development ($HOME/Qt/5.15.2/gcc_64/lib). Is there a way to specify the one located in $HOME, similar to what can be done with a -qmake CLI option (or setting PATH variable to Qt's bin dir) for linuxdeployqt?

probonopd commented 2 years ago

What happens if you export LD_LIBRARY_PATH=$HOME/Qt/5.15.2/gcc_64/lib?

yuriymacdev commented 2 years ago

Thanks for the reply @probonopd, no, that didn't work, the script still uses the system directory.

probonopd commented 2 years ago

I don't quite remember how we determine this. To be investigated.

yuriymacdev commented 2 years ago

I don't quite remember how we determine this. To be investigated.

From what I can see here https://github.com/probonopd/go-appimage/blob/master/src/appimagetool/appdirtool.go, first the script searches standard library directories, then dirs specified in /etc/ld.so.conf, and only then LD_LIBRARY_PATH. Perhaps it makes sense to change the order to look at LD_LIBRARY_PATH first?

I wasn't able to build the project myself (build instructions in Readme.md seem to be outdated?).

probonopd commented 2 years ago

That might be worth a try indeed.

I wasn't able to build the project myself

Do what https://github.com/probonopd/go-appimage/blob/master/.github/workflows/build.yaml does: Essentially, run ./scripts/build.sh -a amd64

yuriymacdev commented 2 years ago

Thanks, it built.

So, two things made the script pick up my Qt installation directory:

  1. I moved LD_LIBRARY_PATH up the list of directories scanned.
  2. qtPrfxpath, that the script tries to extract from a libQt5Core.so.5, is incorrect (it contains a hardcoded path of the user who created the build), so I temporarily hardcoded the string with my own Qt directory.

Perhaps it makes sense to introduce an optional env variable for the Qt installation directory that considers these things.

probonopd commented 2 years ago

When you run your application before using go-appimage, then it picks up the correct Qt, right? We need to find out how that works. Then we can use that information instead of relying on qtPrfxpath, which indeed can be wrong (and often is). I really want these things to "just work" without the need for configuration. Every configuration option is cumbersome to support and an opportunity to screw up for users.