Building HDFView 3.1.0 on CentOS 6: swt library not found

Hi,
Sorry if the problem is stupid, for I have to idea how the Java development goes…
The target is a CentOS 6.10 x64 machine.
I’ve managed to install HDF5 1.10.5 and HDF 4.2.14 on the machine, both with Java enabled, into /usr/lib64.
The Java SDK is of version 11.0.3+12-LTS from Oracle.
The ANT is binary downloaded from Apache, of version 1.10.5.

I edited the build.properties and change these values:
hdf.lib.dir = /usr/lib64
hdf5.lib.dir = /usr/lib64
hdf5.plugin.dir = /usr/lib64/plugin
to reflect the HDF/HDF5 libdir.

The building completes with the error:

[java] Exception in thread “main” java.lang.UnsatisfiedLinkError: Could not load SWT library. Reasons:
[java] no swt-pi4-gtk-4922r32 in java.library.path: [/usr/lib64]
[java] no swt-pi4-gtk in java.library.path: [/usr/lib64]
[java] Can’t load library: /root/.swt/lib/linux/x86_64/libswt-pi4-gtk-4922r32.so
[java] Can’t load library: /root/.swt/lib/linux/x86_64/libswt-pi4-gtk.so

The HDFView seems to have the SWT included in the source, but I don’t know what’s the libswt-pi4-gtk.so is.
From what I’ve read, it’s the SWT interface (JNI?) to the system graphics library.
I tried to download the SWT source (4.1.0) from Eclipse, but it looks like it’s for GTK 3+, and the CentOS 6 did not provide GTK3 packages in its repository.
The ANT can make the package, but the HDFView installed with the package can’t run, with the missing libswt-pi4-gtk.so error.
I think I’m close…

Hi @mike.scchen,

could you look and see if there are any actual files located under ‘/root/.swt/lib/linux/x86_64/’? It’s possible that there may be a version mismatch between the SWT .jar file included in the HDFView source and the one needed specifically for CentOS 6.10. For example, under ‘/root/.swt/lib/linux/x86_64/’ there may be a ‘libswt-pi3-gtk.so’ file or similar, whereas SWT is trying to find ‘libswt-pi4-gtk.so’.

Hi,
There are two files there:

[root@smoke x86_64]# pwd
/root/.swt/lib/linux/x86_64
[root@smoke x86_64]# ls
libswt-gtk-4922r32.so libswt-pi3-gtk-4922r32.so

These files are installed by the HDFView on the first run; if I rename the .swt folder, the error will be like this:

[root@smoke 3.1.0]# sh hdfview.sh
Exception in thread “main” java.lang.UnsatisfiedLinkError: org.eclipse.swt.internal.gtk.OS._cachejvmptr()V
at org.eclipse.swt.internal.gtk.OS._cachejvmptr(Native Method)
at org.eclipse.swt.internal.gtk.OS.cachejvmptr(OS.java:488)
at org.eclipse.swt.internal.gtk.OS.(OS.java:91)
at org.eclipse.swt.internal.Converter.wcsToMbcs(Converter.java:209)
at org.eclipse.swt.internal.Converter.wcsToMbcs(Converter.java:155)
at org.eclipse.swt.widgets.Display.(Display.java:151)
at hdf.view.HDFView.main(HDFView.java:2459)

And the “libswt not found” will appear if I try to run it again.

I’m asking the user if he can use CentOS 7 instead…

Mike

As I suspected, it looks like the SWT .jar included with HDFView is too new for CentOS 6.10. Until we can determine a way of picking among different SWT .jar versions at build time, you should be able to grab a compatible SWT 4.9 jar from this link:

https://download.eclipse.org/eclipse/downloads/drops4/R-4.9-201809060745/download.php?dropFile=swt-4.9-gtk-linux-x86_64.zip

and then take the swt.jar file inside the zip file and replace the one under the /lib/ext/swt/linux/x86_64/ directory in the HDFView source. If that still doesn’t happen to work for you, please let me know and I’ll investigate further into this.

Hi,
Yes the SWT has dependency on GTK, and version 4.10+ requires GTK3, that CentOS 6 does not provide.
So using SWT 4.9 is reasonable.
I tried to replace the swt.jar by your suggestion, and it works - at least the GUI shows up at the “ant run” step, with warning of:

 [java] ***WARNING: SWT requires Cairo 1.9.4 or newer
 [java] ***WARNING: Detected: 1.8.8

But I think I can build a newer Cairo and place it with the hdfview/lib.
Thanks for solving the problem!

Mike