Compiling Java MapScript on Mac OS X

Z Kissane zkissane at SBCGLOBAL.NET
Mon Oct 22 14:40:53 EDT 2007


Short version:  I'm trying to get the Java Mapscript
shared library to compile on OS X Tiger.  I've been
trying to hack the Makefile to get it to work. 
Everything compiles just fine (including the jar
file), it's the linker that's giving me grief.  Both
Mapserver 4.10 and Mapserver 5 will not build the Java
Mapscript shared library "out of the box" as far as I
can tell.  I have followed the guide  at kyngchaos.com
to get Mapserver itself to build, which works just
fine.

Longer version:  The linker for OS X is a little bit
"special".  I don't know if I'm supposed to be using
ld via g++, ld on its own, or libtool.  Also, the Sun
JVM for OS X is "special" in its own right; it
requires JNI libraries passed to the JVM to be named
<libname>.jnilib.    It will ignore libraries like
<libname>.so.  I found this out after I had tabled the
project, but had actually produced some .so output
files (which the JVM was ignoring even though I was
passing their directory to java.library.path).  I
renamed them one by one to libmapscript.jnilib , and
it turned out that one of them did, in fact work, but
by then I had tried something else with the Makefile,
wiping out the "good" settings.

Basically, I can't remember what combination of g++,
ld, libtool, -dynamic, -dynamiclib, and -bundle or
whatever got me the file that worked.  If you're
playing along at home, I do know that you have to hack
the JAVA_INCLUDE variable in the Makefile to point at
the proper location for the Java headers; mine is
/Developer/SDKs/MacOSX10.4u.sdk/System/Library/Frameworks/JavaVM.framework/Versions/1.5.0/headers
I also know that, out of the box (or rather, after you
run configure in the main Mapserver build) that the
SUP_LIBS variable incorrectly uses the iconv header
variable, ICONV_INC, rather than the iconv library
variable, ICONV_LIB, which drove me nuts for a couple
of hours.  You may also get linker errors because it
tries to use gcc to link instead of g++, which means
it gets cut off from some C++ libraries that it needs;
I don't know, all the problems have kind of blurred
together at this point.  But if somebody can just tell
me which tool and which options will produce the
library I would be most grateful.

Thanks,
Zach Kissane
zkissane at sbcglobal.net



More information about the mapserver-users mailing list