[Gdal-dev] Java SWIG bindings
Norman Barker
nbarker at rsinc.com
Fri Feb 3 10:46:36 EST 2006
-----Original Message-----
From: gdal-dev-bounces at lists.maptools.org
[mailto:gdal-dev-bounces at lists.maptools.org]On Behalf Of Collins,
Benjamin
Sent: Friday, February 03, 2006 3:17 PM
To: gdal-dev at lists.maptools.org
Subject: RE: [Gdal-dev] Java SWIG bindings
In a preemptive move against any questions about how to use the
bindings, I will give these short directions:
0.5. Make sure that swig/java/java.opt points to your java (JDK)
installation.
1. Compile the SWIG wrappers into the C/C++ files and Java files. The
result will be four C/C++ sources (which link between a JNI interface
and the GDAL/OGR DLL) and a number of Java source files in the
org/gdal/* directories that have a Plain Old Java Oject (POJO)
structure that calls into the JNI code. This is already done in the
source tree since there is no binary code generation, just source
generation.
2. Compile the C/C++ files into DLLs and the Java source files to a
jar. This can be done by going into the swig/java directory and
calling 'make build' on GNU platforms (including cygwin) or running
'nmake -f makefile.vc' on MS platforms. If the jar is not built for
you, run 'ant' and the java sources should be compiled into gdal.jar.
Now you have
- .libs/lib*jni.so
- gdal.jar
3. Import what you need of gdal.jar into your source and go! An
example is in the apps directory and is called gdalinfo.java. Here's
how to get it running:
- Go into the apps directory.
- Compile with 'javac -classpath ../gdal.jar gdalinfo.java'
- Run with 'java -cp ../gdal.jar -Djava.library.path=../.libs/
gdalinfo <filename>'
That's it!
--
Ben Collins
<snip>
hi Ben,
at the risk of sounding stupid, I have done the following on RHEL3 after doing ./configure, make as in the normal GDAL build.
cd swig -> make
cd java -> make
I get the following errors
mkdir -p org/gdal/gdal
mkdir -p org/gdal/gdalconst
mkdir -p org/gdal/ogr
mkdir -p org/gdal/osr
shared ../../libgdal.la gdal_wrap.o -o libgdaljni.so
make: shared: Command not found
make: [libgdaljni.so] Error 127 (ignored)
shared ../../libgdal.la ogr_wrap.o -o libogrjni.so
make: shared: Command not found
make: [libogrjni.so] Error 127 (ignored)
shared ../../libgdal.la gdalconst_wrap.o -o libgdalconstjni.so
make: shared: Command not found
make: [libgdalconstjni.so] Error 127 (ignored)
shared ../../libgdal.la osr_wrap.o -o libosrjni.so
make: shared: Command not found
make: [libosrjni.so] Error 127 (ignored)
cp ./.libs/*.so ./
cp: cannot stat `./.libs/*.so': No such file or directory
make: *** [build] Error 1
Do you have windows, and linux binaries of this at all? I would like to get it compiling from source if possible.
Many thanks,
Norman
More information about the Gdal-dev
mailing list