Changes between Version 5 and Version 6 of GdalOgrInJavaBuildInstructionsUnix


Ignore:
Timestamp:
Oct 6, 2009, 3:28:54 PM (15 years ago)
Author:
Even Rouault
Comment:

update with how to build on MinGW

Legend:

Unmodified
Added
Removed
Modified
  • GdalOgrInJavaBuildInstructionsUnix

    v5 v6  
    1 = Building GDAL/OGR Java Bindings on Linux/Unix =
     1= Building GDAL/OGR Java Bindings on Linux/Unix/MinGW =
    22
    3 Tested with gdal-1.5.2.
     3Tested with gdal-1.5.2 and GDAL 1.7.0
    44
    55== Configure and Build GDAL ==
     6
     7You need swig in the path.
    68
    79I found I had to configure GDAL --without-libtool to get the java bindings to build.
     
    1113== Update java.opt ==
    1214
    13 Replace/Create gdal/swig/java/java.opt with an appropriate local version.  Make sure the windows backslashes are turned to forward slashes, and point to your local Java SDK.  The ANT_HOME isn't used on linux where it is apparently assumed ant will be in the path.
     15Replace/Create gdal/swig/java/java.opt with an appropriate local version.  Make sure the windows backslashes are turned to forward slashes, and point to your local Java SDK.  ant is assumed to be in the path.
    1416
    1517{{{
    1618JAVA_HOME = /home/warmerda/pkg/jdk1.6.0_10
    17 #ANT_HOME=c:\programmi\apache-ant-1.7.0
    1819JAVADOC=$(JAVA_HOME)/bin/javadoc
    1920JAVAC=$(JAVA_HOME)/bin/javac
     
    2627
    2728See this ticket http://trac.osgeo.org/gdal/ticket/2401 for a patch and java.opt for building the java bindings on Leopard
     29
     30=== Win32 MinGW ===
     31
     32Tested with GDAL 1.7.0. Building the Java bindings under MinGW is possible but requires a bit of patching :
     33
     34* Update the JAVA_HOME variable in gdal/swig/java/java.opt and change the JAVA_INCLUDE variable to the following value :
     35{{{
     36JAVA_INCLUDE=-I$(JAVA_HOME)/include -I.
     37}}}
     38 
     39* in swig/java/GNUmakefile, we ensure that the name of the DLLs are not prefixed by lib, by changing the 'JAVA_MODULES= libgdaljni.$(SO_EXT)...' and '$(JAVA_MODULES): %jni.$(SO_EXT)...' lines to be
     40
     41{{{
     42JAVA_MODULES = gdaljni.$(SO_EXT) ogrjni.$(SO_EXT) gdalconstjni.$(SO_EXT) osrjni.$(SO_EXT)
     43}}}
     44
     45and
     46
     47{{{
     48$(JAVA_MODULES): %jni.$(SO_EXT): %_wrap.$(OBJ_EXT)
     49}}}
     50
     51* Create a jni_md.h file in gdal/swig/java directory with the following content that ensures thanks to the empty JNICALL that the symbols in the *jni.dll have the proper decorations
     52
     53{{{
     54#ifndef _GDAL_JNI_MD_H_
     55#define _GDAL_JNI_MD_H_
     56
     57#define JNIEXPORT __declspec(dllexport)
     58#define JNIIMPORT __declspec(dllimport)
     59#define JNICALL
     60
     61typedef long jint;
     62typedef __int64 jlong;
     63typedef signed char jbyte;
     64
     65#endif
     66}}}
     67
     68Then run make from gdal/swig/java.  and the GDAL DLL is in the path, "java -cp "gdal.jar;build/apps" gdalinfo" should work.
    2869
    2970== Run the java build ==
     
    63104}}}
    64105
     106Starting with GDAL 1.7.0, the utilities are automatically built in the swig/java/build/apps directory. So after building, you can just do
     107
     108{{{
     109setenv LD_LIBRARY_PATH ${LD_LIBRARY_PATH}:`pwd`
     110java -classpath `pwd`/gdal.jar:`pwd`:`pwd`/build/apps gdalinfo
     111}}}
     112
    65113With luck you will see the gdalinfo usage message.
    66114