georust / gdal

Rust bindings for GDAL
https://crates.io/crates/gdal
MIT License
369 stars 94 forks source link

Unable to open JPEG compressed GeoTiff in Ubuntu 22.04 #444

Open frapa opened 1 year ago

frapa commented 1 year ago

Hi,

I have written a program that uses the gdal crate to read some parts of a GeoTiff file. The file is RGB data and uses JPEG compression. With any other compressions (I tested none and LZW) everything works as expected, but with JPEG on Ubuntu 22.04 the program fails to load the libjpeg shared lib:

ERROR 1: JPEGLib:Wrong JPEG library version: library is 62, caller expects 80
tif_jpeg.c:1021: JPEGSetupDecode: Assertion `sp->cinfo.comm.is_decompressor' failed.

Process finished with exit code 134 (interrupted by signal 6: SIGABRT)

Note that my installed version of libjpeg is 8, I do not have version 6.2 on the system:

$ apt list --installed | grep jpeg
libjpeg-turbo8-dbg/jammy,now 2.1.2-0ubuntu1 amd64 [installed,automatic]
libjpeg-turbo8-dev/jammy,now 2.1.2-0ubuntu1 amd64 [installed]
libjpeg-turbo8/jammy,now 2.1.2-0ubuntu1 amd64 [installed,automatic]
libjpeg-turbo8/jammy,now 2.1.2-0ubuntu1 i386 [installed,automatic]
libjpeg8-dbg/jammy,now 8c-2ubuntu10 amd64 [installed]
libjpeg8-dev/jammy,now 8c-2ubuntu10 amd64 [installed]
libjpeg8/jammy,now 8c-2ubuntu10 amd64 [installed]
libjpeg8/jammy,now 8c-2ubuntu10 i386 [installed,automatic]

$ ls /usr/lib/x86_64-linux-gnu/libjpeg* -l
-rw-r--r-- 1 root root 820348 feb 21  2022 /usr/lib/x86_64-linux-gnu/libjpeg.a
lrwxrwxrwx 1 root root     12 feb 21  2022 /usr/lib/x86_64-linux-gnu/libjpeg.so -> libjpeg.so.8
lrwxrwxrwx 1 root root     16 ago  7 18:45 /usr/lib/x86_64-linux-gnu/libjpeg.so.8 -> libjpeg.so.8.2.2
-rw-r--r-- 1 root root 522960 feb 21  2022 /usr/lib/x86_64-linux-gnu/libjpeg.so.8.2.2
lrwxrwxrwx 1 root root     16 gen 28  2022 /usr/lib/x86_64-linux-gnu/libjpegxr.so.0 -> libjpegxr.so.1.2
-rw-r--r-- 1 root root 223592 gen 28  2022 /usr/lib/x86_64-linux-gnu/libjpegxr.so.1.2

The interesting thing is that using my installed GDAL for instance with gdal_translate or QGIS works as expected (reading JPEG compressed tiffs just fine), it's just rust programs using this library and dynamically linking to GDAL which fails to load.

I have tried on 3 different systems, all with Ubuntu 22.04, and none of them seems to work. I used apt to install GDAL (version 3.4).

lnicola commented 1 year ago

I'm also inclined to think this is a version mismatch. How did you build your program, was it on this computer or somewhere else? Can you try building and running it in a container to isolate it from the rest of your system?

And does a simple program that just reads the three bands (for example) have the same issue?

metasim commented 1 year ago

@frapa Do you by chance use conda or some other Python environment management system? I've had problems with it polluting the link environment during builds. I agree with @lnicola that this is a library version problem (gdal build against one jpeg library, but loading a different library at runtime.

metasim commented 1 year ago

@frapa Also could you paste the output of this?

gdalinfo --formats | grep -i jpeg
gdalinfo --formats | grep -i tif

(may or may not be helpful, but can compare to what's in our CI environment)

lnicola commented 1 year ago

@frapa are you still having this issue?