Changes between Version 1 and Version 2 of GdalOgrInJavaBuildInstructions


Ignore:
Timestamp:
Jan 31, 2008, 8:13:11 AM (16 years ago)
Author:
allanx13
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • GdalOgrInJavaBuildInstructions

    v1 v2  
    11
    2 = Build Instructions for GDAL/OGR In Java =
     2= Build Instructions for GDAL/OGR In Java (Windows) =
     3
     4'''NOTES'''
     5
     6(1) These instructions were written in January 2008.
     7
     8(2) GEOS is included here, but it is not necessary.
     9
     10(3) MS Visual C++ is required for compiling various packages. Version 7 has been tested and has no problems; older/newer versions should work, but have not been tested.
     11
     12(4) Version numbers in parentheses are the latest versions available for each given package (except for packages where a specific version is required).
     13
     14(5) ''<geos-dir>'' refers to the directory where GEOS is installed. ''<gdal-dir>'' refers to the directory where GDAL is installed. ''<java-dir>'' refers to the directory where Java is installed. ''<ant-dir>'' refers to the directory where Apache Ant is installed.
     15
     16'''1. Compile GEOS 2.2.3'''
     17
     18[http://geos.refractions.net]
     19
     20I couldn't get the latest version, 3.0.0, to compile on my PC with MS VC7; however, there are project files for MS VC8 available that could be tried. However, version 2.2.3 was good enough for what I needed.
     21
     22a. Download [http://svn.osgeo.org/geos/trunk/source/headers/geos/version.h.vc] and place it in ''<geos-dir>''\source\headers\geos. Edit the following lines:
     23{{{
     24#define GEOS_VERSION_MAJOR 3    - change 3 to 2
     25#define GEOS_VERSION_MINOR 0    - change 0 to 2
     26#define GEOS_VERSION_PATCH 0rc4 - change 0rc4 to 2
     27#define GEOS_VERSION "3.0.0rc4" - change 3.0.0rc4 to 2.2.3
     28}}}
     29
     30b. Rename ''<geos-dir>''\source\capi\geos_c.h.in to geos_c.h.vc.
     31
     32c. Run MSVC's vcvars32.bat
     33
     34d. In the "source" directory, run "nmake -f makefile.vc"
     35
     36'''2. Install the latest version of SWIG (1.3.33)'''
     37
     38[http://www.swig.org/download.html]
     39
     40A Windows version with a pre-built executable is available, so compiling isn't necessary.
     41
     42'''3. Install the latest version of the Java SE Development Kit (1.6.0_03)'''
     43
     44[http://java.sun.com/javase/downloads/index.jsp]
     45
     46'''4. Install the latest version of Apache Ant (1.7.0)'''
     47
     48[http://ant.apache.org/bindownload.cgi]
     49
     50Binary distributions are available, so compiling isn't necessary.
     51
     52'''5. Set up environment variables'''
     53
     54a. In the Control Panel, open up System. Switch to the Advanced tab and click on Environmental Variables.
     55
     56b. In the System Variables pane, look for CLASSPATH. If it exists, click on "Edit" and ensure that "." and "..\gdal.jar" are included. Individual items are separated by colons. If CLASSPATH does not exist, click on "New" and add CLASSPATH with the same two locations.
     57
     58c. Do the same for PATH. Ensure that "''<java-dir>''\bin" and "''<ant-dir>''\bin" are included in PATH.
     59
     60'''6.   Compile GDAL 1.4.4 with GEOS'''
     61
     62[http://trac.osgeo.org/gdal/wiki/DownloadSource]
     63
     64GDAL 1.5's Java bindings are orphaned and are believed to be broken, so we'll stick with 1.4.4 for now.
     65
     66a. Open <''gdal-dir''>\nmake.opt and make the following changes:
     67{{{
     68- Change the value of SWIG to the location of swig.exe (ex. SWIG = c:\progra~1\swigwin-1.3.33\swig.exe).
     69- Uncomment the GEOS_CFLAGS and GEOS_LIB lines.
     70- Change the value of GEOS_CFLAGS to the source/capi directory in the GEOS installation (ex. GEOS_CFLAGS = -Ic:\geos-2.2.3\source\capi -DHAVE_GEOS).
     71- Change the value of GEOS_LIB to the location of geos_c_i.lib (ex. GEOS_LIB = c:\geos-2.2.3\source\geos_c_i.lib).
     72}}}
     73
     74b. Run MSVC's vcvars32.bat
     75
     76c. In ''<gdal-dir>'', run "nmake -f makefile.vc".
     77
     78'''7. Compile GDAL's Java bindings'''
     79
     80a. Run MSVC's vcvars32.bat
     81
     82b. In ''<gdal-dir>''\swig, run "nmake -f makefile.vc java".
     83
     84c. Move the following files from ''<gdal-dir>''\swig\java to ''<gdal-dir>''\swig\java\apps:
     85{{{
     86- gdalconstjni.dll
     87- gdaljni.dll
     88- ogrjni.dll
     89- osrjni.dll
     90}}}
     91
     92d. Copy the following files from ''<geos-dir>''\source to ''<gdal-dir>''\swig\java\apps:
     93{{{
     94- geos.dll
     95- geos_c.dll
     96}}}
     97
     98e. Check that ''<gdal-dir>''\swig\java\gdal.jar has been created. If it has not been created, run “ant” in the ''<gdal-dir>''\swig\java directory to compile the Java sources into gdal.jar.
     99
     100'''8. Compile and run Java applications'''
     101
     102a. Place a Java source file in ''<gdal-dir>''\swig\java\apps.
     103
     104b. Open a command line window (i.e., "cmd") and change directory to ''<gdal-dir>''\swig\java\apps.
     105
     106c. To compile a Java file, enter "javac ''<file>''.java".
     107
     108d. To launch a Java application, enter "java ''<class>''".