Skip to content

Instantly share code, notes, and snippets.

@zhm
Created March 5, 2012 00:55
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save zhm/1975726 to your computer and use it in GitHub Desktop.
Save zhm/1975726 to your computer and use it in GitHub Desktop.
Building GDAL 1.9 with MDB (PGeo) support on OS X Lion
- Download and install the "Java for Mac OS X 10.7 Update 1 Developer Package" from https://developer.apple.com/downloads/index.action
- Download jackcess-1.2.6.jar from http://sourceforge.net/projects/jackcess/files/jackcess/1.2.6/jackcess-1.2.6.jar/download
- Download http://mdb-sqlite.googlecode.com/files/mdb-sqlite-1.0.2.tar.bz2 to get commons-lang-2.4.jar and commons-logging-1.1.1.jar. They will go alongside jackcess in the $CLASSPATH after it builds.
- In the GDAL source root, edit the configure.in and replace it with https://gist.github.com/1975654
- In the GDAL source root, run ./autogen.sh to re-create the configure script
- ./configure --with-java=yes --with-mdb=yes --with-jvm-lib=/System/Library/Frameworks/JavaVM.framework/Libraries
- make && make install (I suggest a custom --prefix with ./configure so you don't conflict with other versions of GDAL, e.g. homebrew)
- Copy jackcess-1.2.6.jar, commons-lang-2.4.jar, and commons-logging-1.1.1.jar to /Library/Java/Extensions so java can find them.
- Test it out ./ogr2ogr -f "SQLite" ~/data/test_output.sqlite ~/data/test_input.mdb
@oeon
Copy link

oeon commented Mar 5, 2012

ran into this...researching.

checking whether we should include Java support... configure: error: "/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home is not a valid JDK."

@zhm
Copy link
Author

zhm commented Mar 5, 2012

What's in that directory? The configure script checks that there's an 'include' directory.

ls -al `/usr/libexec/java_home`

@oeon
Copy link

oeon commented Mar 5, 2012

lrwxr-xr-x  1 root  wheel  79 Mar  4 17:21 /usr/libexec/java_home -> /System/Library/Frameworks/JavaVM.framework/Versions/Current/Commands/java_home

@zhm
Copy link
Author

zhm commented Mar 5, 2012

/usr/libexec/java_home

returns /Library/Java/JavaVirtualMachines/1.6.0_29-b11-402.jdk/Contents/Home on my machine, which does have the include directory

@zhm
Copy link
Author

zhm commented Mar 5, 2012

On line 3351 of configure.in:

with_java=`/usr/libexec/java_home`

You can try hardcoding this just to get it to work, I haven't completely figured out how the java config works, but it seems java_home might be a different path on your machine.

So it would become something like:

with_java="/Library/Java/JavaVirtualMachines/1.6.0_29-b11-402.jdk/Contents/Home"

Go to that path on your machine and see if there's an include directory, if so, that should be the right one.

@zhm
Copy link
Author

zhm commented Mar 5, 2012

If anyone else is interested, I based my configure.in changes on another project I found that does similar linking to java. This script seems more robust and I think the GDAL configure script should be re-worked to be closer to this one.

http://code.google.com/p/vrjuggler/source/browse/dpp/config/java.m4?spec=svnc318ebbebf30d820193d7919a455cedf15c5e38d&name=2.2&r=c318ebbebf30d820193d7919a455cedf15c5e38d

@oeon
Copy link

oeon commented Mar 5, 2012

aiight. I think I'm rolling now - I installed javadeveloper_for_mac_os_x_10.7__11m3527.dmg from https://developer.apple.com/downloads/index.action?name=Java%20Developer and in Java Preferences.app and disabled 1.6.0_29-b11-402 where Name was Java SE 6 (System), leaving to remaining two entries without (System). Don't know how I got all jacked w/ Java there...

@zhm
Copy link
Author

zhm commented Mar 5, 2012

Sweet!

@patdevinwilson
Copy link

If you're on Yosemite, you'll can find Java http://osxdaily.com/2014/10/21/get-java-os-x-yosemite/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment