Skip to content
eightysteele edited this page Jun 20, 2012 · 3 revisions

Compiling GDAL

forma-clj requires GDAL 1.8.0's native java bindings. These can be a bit of a pain to acquire, and must be built for the system you plan on using.

Building on Ubuntu

First download, configure, and make GDAL:

$ curl -O http://download.osgeo.org/gdal/gdal-1.9.1.tar.gz
$ tar xvfz gdal-1.9.1.tar.gz
$ cd gdal-1.9.1
$ ./configure --with-java=yes
$ make

Next edit gdal-1.9.1/swig/java/java.opt with your JAVA_HOME path:

JAVA_HOME = "/usr/lib/jvm/java-6-openjdk-amd64"
JAVADOC=$(JAVA_HOME)/bin/javadoc
JAVAC=$(JAVA_HOME)/bin/javac
JAVA=$(JAVA_HOME)/bin/java
JAR=$(JAVA_HOME)/bin/jar
JAVA_INCLUDE=-I$(JAVA_HOME)/include -I$(JAVA_HOME)/include/linux

Almost there! Just make it:

$ cd gdal-1.9.1/swig/java/
$ make

And finally copy the resulting .so files into a directory and update your LD_LIBRARY_PATH environment variable to point to them:

$ cd /gdal-1.9.1/swig/java
$ ls | grep .so
libgdalconstjni.so
libgdaljni.so
libogrjni.so
libosrjni.so
$ cp *.so ~/opt/linuxnative/
$ export LD_LIBRARY_PATH=~/opt/linuxnative/ # Put this in .bashrc

POM.xml

Add the following to pom.xml:

<?xml version="1.0" encoding="UTF-8"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <modelVersion>4.0.0</modelVersion>
  <groupId>forma</groupId>
  <artifactId>gdal</artifactId>
  <version>1.8.0</version>
  <name>gdal</name>
</project>

Then run

scp pom.xml gdal.jar clojars@clojars.org:
Clone this wiki locally