App crashes when using jpegs
-
My application always crashes when using jpegs in release mode, no matter on which linux distro (I have tested ubuntu, manjaro and fedora). Even if I just use:
QImage test("/home/creapermann/Downloads/pexels-photo-551628-907132679.jpg", "jpeg");
It crashes in release mode, but it works just fine in debug mode though.
-
@Creaperdown try without the `"jpeg" argument:
QImage test("/home/creapermann/Downloads/pexels-photo-551628-907132679.jpg");
-
Ah, I have just seen this message right before it crashes
-
@Creaperdown your jpg library is too new, it seems. Install an older version or compile Qt with built-in jpg library.
-
@Creaperdown oh so this is a flatpak? Then you absolutely can ship your own Qt with it, if I understand it well (which I don't; I've got more experience with AppImage).
Anyway, I don't see another way to be honest. Except maybe if you shipped your own JPG lib and linked to it with
rpath
, but that it a hacky solution. -
@sierdzio Its not just flatpak, we are distributing the application through multiple repositories, for example: flatpak, snap, the AUR, ... Non of these work with jpegs.
Also, the jpegs actually used in the application are downloaded from the internet, so I can not pre-download them.
-
@sierdzio ok, I think I found something. Looking at the output that valgrind gives me, it seems like Qt uses the libjpeg version of a dependency of my project:
This would explain the library version mismatch. Do you have an idea on how I could tell Qt what library to use?
-
@Creaperdown Point it to the right place with
rpath
orLD_LIRARY_PATH
if you are using a launch script of some sort. -
@Creaperdown
rpath
then. But the proper solution would be to sort out your dependencies so that all libs use only one version of the jpg library. -
@sierdzio well, a dependency of my project builds a specific libjpeg version itself, and I do not have any control over that. Qt needs a newer version but it seems to choose the libjpeg that is built by the library and not the one available on the system.
-
@Creaperdown
That choice ought to depend on some mixture of that library's location relative to Qt's libraries,LD_LIRARY_PATH
and/orrpath
.You might get a clue where it is looking when by running your app under
strace
. I don't know if there is a better tool to diagnose this. -
@JonB This problem only occurs when trying to deploy my application using flatpak. Building it on my machine normally works just fine. I would prefer not to hard code an
rpath
into my application since I suppose that this will just lead to issues andLD_LIRARY_PATH
didn't help me either. Also, I do not understand howstrace
could help me with my problem. I tried it non-the less but didn't manage to get any valuable information from it. -
@Creaperdown you may have to wrap the right lib with or statically link it to your app in this case.
rpath will lead your app to look for the linked libs first in a specified dir if your know exactly where the libs are located.
LD_LIRARY_PATH will not work if your app is launched when os starts. But you can start your app as:
env LD_LIRARY_PATH=... your app.ldd your app
to make sure your app is linked to the right lib.