[gdal-dev] Compiling GDAL JNI libraries

Sunil Padda sunilkp at yahoo-inc.com
Tue Jul 24 03:55:45 PDT 2012


Hi,

I am trying to compile GDAL with Java bindings, but am facing issues. 
Here is what I have done:
1. Download gdal source from http://trac.osgeo.org/gdal/wiki/DownloadSource
2. Build gdal libraries
     cd gdal
     ./configure
     make
     sudo make install
3. Install SWIG
4. Update JAVA_HOME in gdal/swig/java/java.opt
5. Build gdal JNI
     cd gdal/swig/java
     make

I am seeing errors like this:
wanthunger-dx 16:00:56 ~/downloads/gdal-1.9.1/swig/java $ make
mkdir -p org/gdal/gdal
mkdir -p org/gdal/gdalconst
mkdir -p org/gdal/ogr
mkdir -p org/gdal/osr
/bin/sh /home/sunilkp/downloads/gdal-1.9.1/libtool --mode=compile 
--tag=CXX g++ -fno-strict-aliasing -g -O2  -Wall 
-Wdeclaration-after-statement -I/home/sunilkp/downloads/gdal-1.9.1/port 
-I/home/sunilkp/downloads/gdal-1.9.1/gcore 
-I/home/sunilkp/downloads/gdal-1.9.1/alg 
-I/home/sunilkp/downloads/gdal-1.9.1/ogr 
-I/home/sunilkp/downloads/gdal-1.9.1/ogr/ogrsf_frmts 
-I"/home/y/libexec/jdk1.6.0"/include 
-I"/home/y/libexec/jdk1.6.0"/include/linux -c gdal_wrap.cpp
libtool: compile:  g++ -fno-strict-aliasing -g -O2 -Wall 
-Wdeclaration-after-statement -I/home/sunilkp/downloads/gdal-1.9.1/port 
-I/home/sunilkp/downloads/gdal-1.9.1/gcore 
-I/home/sunilkp/downloads/gdal-1.9.1/alg 
-I/home/sunilkp/downloads/gdal-1.9.1/ogr 
-I/home/sunilkp/downloads/gdal-1.9.1/ogr/ogrsf_frmts 
-I/home/y/libexec/jdk1.6.0/include 
-I/home/y/libexec/jdk1.6.0/include/linux -c gdal_wrap.cpp  -fPIC -DPIC 
-o .libs/gdal_wrap.o
cc1plus: warning: command line option "-Wdeclaration-after-statement" is 
valid for C/ObjC but not for C++
gdal_wrap.cpp: In function `_jstring* 
Java_org_gdal_gdal_gdalJNI_get_1Driver_1ShortName(JNIEnv*, _jclass*, 
jlong)':
gdal_wrap.cpp:4600: error: `GDALDriverShadow_get_ShortName' was not 
declared in this scope
gdal_wrap.cpp:4600: warning: unused variable 
'GDALDriverShadow_get_ShortName'

I don't have experience in C++ or Make, so couldn't figure out how to 
fix this. But, it looks like some problem with a) referenced gdal c++ 
headers/libraries or b) invalid compiler options

It would be great if you can help me fix this issue.

Thanks,
Sunil


More information about the gdal-dev mailing list