Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 752399 - sci-libs/gdal-3.0.4-r1[java] needs to install
Summary: sci-libs/gdal-3.0.4-r1[java] needs to install
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: Sci-geo Project
Depends on:
Reported: 2020-11-03 00:30 UTC by Khumba
Modified: 2020-11-05 03:20 UTC (History)
1 user (show)

See Also:
Package list:
Runtime testing required: ---

emerge --info (emerge-info.txt,6.54 KB, text/plain)
2020-11-03 00:30 UTC, Khumba

Note You need to log in before you can comment on or make changes to this bug.
Description Khumba 2020-11-03 00:30:33 UTC
GDAL uses SWIG to generate its Java bindings, and there are two parts outputs from this: gdal.jar, and the native that the JAR references.  The ebuild installs gdal.jar but not the .so, and trying to run a Java project that uses GDAL results in:

    Native library load failed.
    java.lang.UnsatisfiedLinkError: no gdalalljni in java.library.path: [/usr/java/packages/lib, /usr/lib64, /lib64, /lib, /usr/lib]

I think this is a simple oversight.  These files exist in the work directory:

# (cd /var/tmp/portage/sci-libs/gdal-3.0.4-r1 && ls -l $(find -iname '*gdalalljni*'))
-rw-r--r-- 1 portage portage   1693 Nov  2 15:21 ./work/gdal-3.0.4/swig/java/
-rwxr-xr-x 1 portage portage 686328 Nov  2 15:21 ./work/gdal-3.0.4/swig/java/
lrwxrwxrwx 1 portage portage     19 Nov  2 15:21 ./work/gdal-3.0.4/swig/java/.libs/ -> ../
-rw-r--r-- 1 portage portage   1188 Nov  2 15:21 ./work/gdal-3.0.4/swig/java/.libs/libgdalalljni.lai
lrwxrwxrwx 1 portage portage     23 Nov  2 15:21 ./work/gdal-3.0.4/swig/java/.libs/ ->
lrwxrwxrwx 1 portage portage     23 Nov  2 15:21 ./work/gdal-3.0.4/swig/java/.libs/ ->
-rwxr-xr-x 1 portage portage 686328 Nov  2 15:21 ./work/gdal-3.0.4/swig/java/.libs/

I can confirm that adding "${S}"/swig/java/.libs/{,.26,.26.0.4}

into the "use java" conditional in src_install fixes the problem and lets Java load gdal.jar successfully.  (The .../java/ file is just a copy of the .so in .libs, this can be seen in the build log.)
Comment 1 Khumba 2020-11-03 00:30:46 UTC
Created attachment 669809 [details]
emerge --info
Comment 2 Khumba 2020-11-05 03:20:05 UTC
Also, a heads up that if GDAL is built with USE=-threads and used from Java, it issues this warning:

WARNING: GDAL should be compiled with thread support for safe execution in Java.

Rebuilding with USE=threads fixes it.  I'm not sure if this warrants a REQUIRED_USE entry or if this should be left as a soft warning.  There's an FAQ item relating to GDAL thread-safety: