[gdal-dev] UnsatisfiedLinkError with gdal14

MarvinCO marvin.offiah at googlemail.com
Sat Nov 20 16:57:35 EST 2010


Hey,

I am trying to write a Java application that uses GDAL on Windows 7. I am
using the Java bindings of GDAL together with the gdal DLLs from the GDAL
download page.

I hope you are familiar with the distributions I'm using:

GDAL DLLs:
imageio-ext-1.0.5-windows32-dlls/*

GDAL Java bindings:
imageio-ext-1.0.8-libraries/*

I have copied all the DLLs into my jre/bin directory of my Java Runtime
environment.

Everything works fine if I run the program via the Eclilpse run
configuration. GDAL libraries are properly loaded, and are able to read a
shapefile that my program opens and display its contents.

My program starts like this:

package mapillustrator;

import javax.swing.JLabel;
import javax.swing.JOptionPane;

import mapillustrator.controller.Controller;
import mapillustrator.view.MainWindow;

import org.gdal.ogr.ogr;

/*
 * To change this template, choose Tools | Templates and open the template
in
 * the editor.
 */

/**
 * 
 * @author marvin
 */
public class MapIllustrator {

	public static Controller controller;

	public static MainWindow mainWindow;

	public static void main(String[] args) throws Exception {
		try {
			System.loadLibrary("gdal14");
			ogr.RegisterAll();
			controller = new Controller(args[0]);
			mainWindow = new MainWindow(null, true);
		} catch (Exception e) {
			JOptionPane.showMessageDialog(new JLabel(), e.getMessage());
			e.printStackTrace();
		}
	}

}

So, as I said, all this works fine.

However, I now want to have the main method launched via a python script for
some reason, so here's my python script (the script is located at
"C:\Program Files\Inkscape\share\extensions"):

import os, sys, subprocess, time

dir = os.getcwd().replace("\\", "/") + "/share/extensions/MapIllustrator/"
libdir = dir + "lib/"

subprocess.Popen("java -verbose -classpath \".;C:/Program
Files/Java/jre6/lib/ext/QTJava.zip;" + dir + "build/classes;" + libdir +
"*;" + libdir + "SuperCSV-1.52/*;" + libdir + "batik-1.7/*;" + libdir +
"batik-1.7/lib/*;" + libdir + "batik-1.7/extensions/*;" + libdir +
"imageio-ext-1.0.8-libraries/*;" + "\" mapillustrator.MapIllustrator \"" +
sys.argv[-1] + "\"", stdout=True)

But everytime I launch my application via the script I get an
UnsatisfiedLinkError of the kind

"gdal14.dll: Can't find dependent libraries"

I'm really wondering why I am not getting this error if I launch my program
via Eclipse. No such error occurs there and GDAL manages to load all the
libraries and does not complain about any dependencies.
Obviously, the gdal14.dll is found. I'm using the JDK1.6.0.22 with Eclipse.
Its JRE is also configured as the default JRE in my windows registry:

C:\Program Files\Java\jdk1.6.0_21\jre

As I said, I have also copied all files from the
imageio-ext-1.0.5-windows32-dlls/* into the "C:\Program
Files\Java\jdk1.6.0_21\jre\bin". I have also tried copying them to
"C:\Program Files\Java\jdk1.6.0_21\bin" instead. The all Java bindings for
GDAL are also included in the Java classpath in my Eclipse project settings.
As you can see in the Python script, I am also doing that above.

So obviously, there has to be a difference in how Eclipse launches my Java
program and in how the python script does. I don't see any other
explanation, and I also don't know what on earth Eclipse does different to
have it run without a problem. There isn't a single argument set in my run
configuration. I don't know how Eclipse actually transfers the classpath
arguments of the project settings into the program launch (probably adds the
-classpath <...> argument on its own), but other than that I'd really like
to know what I am doing wrong.
The only difference between running from Eclipse and running via my python
script seems to be that my python script is that both are calling java from
a different current working directory: The project home in Eclipse VS
"C:\Program Files\Inkscape" in the script. The script is being launched as
an Inkscape extension. I don't know why Inkscape sets the CWD to 
"C:\Program Files\Inkscape", although it is located at "C:\Program
Files\Inkscape\share\extensions"


-- 
View this message in context: http://osgeo-org.1803224.n2.nabble.com/UnsatisfiedLinkError-with-gdal14-tp5759026p5759026.html
Sent from the GDAL - Dev mailing list archive at Nabble.com.


More information about the gdal-dev mailing list