[mapserver-users] Java MapScript Win32 DLL

Norman Vine nhv at cape.com
Sun Oct 6 08:58:52 EDT 2002


Andrew Collins writes:

> Steps taken:
>
> 1. Compiled MapServer with gcc using MinGW and MSYS.
>
> 2. Generated MapScript C and Java code with swig.

Note I haven't tried building mapserver with MingW MSYS
nor have I tried building Java mapscript but MingW and Cygwin
act VERY much the same and the following reflects my experience
building Python mapscript with Cygwin

====
at the top of the SWIG generated mapscript_wrap.c file
you probably need to adjust the #define for DLL linkage to
something like

#if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__)
#       if defined(_MSC_VER) || defined(__CYGWIN__) || defined( __MINGW32__)
#               if defined(STATIC_LINKED)
#                       define SWIGEXPORT(a) a


>
> 3. Produced dll with dlltool and gcc using MinGW and MSYS.

FYI - There is no need to use dlltool anymore as the latest MingW and Cygwin
gcc can build a dll directly although the method  you use looks OK

Here are the command lines that build python mapscript for me with Cygwin
the same techniques should work for MingW and java mapscript DLL
< you will need to change these to reflect you are building the Java
   library and your local configuration etc. >

gcc -g -O2 -Wall -Wstrict-prototypes -DUSE_DL_IMPORT -DPROJ=-DUSE_PROJ -DUSE
_PROJ_API_H -DGD=-DUSE_GD_PNG -DUSE_GD_JPEG -DUSE_GD_WBMP -DUSE_GD_FT -DJPEG
=-DUSE_JPEG -DIGNORE_MISSING_DATA=-DIGNORE_MISSING_DATA -DOWS=-DUSE_WMS_SVR 
-DUSE_WMS_LYR -DUSE_WFS_SVR -DEPPL=-DUSE_EPPL -DTIFF=-DUSE_TIFF -DGDAL=-DUSE
_GDAL -DOGR=-DUSE_OGR -DPOSTGIS=-DUSE_POSTGIS -I../.. -I/usr/local/include -
I/usr/local/include/python2.1 -c mapscript_wrap.c -o mapscript_wrap.o

gcc -shared -Wl,--enable-auto-image-base mapscript_wrap.o ../../libmap.a
/usr/local/lib/ogr.a -L../.. -L/lib -L/usr/local/lib -L/usr/local/lib/python
2.1/config -lmap -lgd -lfreetype -lproj -lgdal.1.1 -lpq -lwwwinit -lwwwapp -
lwwwxml -lxmlparse -lxmltok -lwwwhtml -lwwwtelnet -lwwwnews -lwwwhttp -lwwwm
ime -lwwwgopher -lwwwftp -lwwwfile -lwwwdir -lwwwcache -lwwwstream -lwwwmux 
-lwwwtrans -lwwwcore -lwwwutils -lmd5 -lm -lpython2.1 -o _mapscript.dll


!!! DO NOT DO THE FOLLOWING !!!

> $ cd mapserver-3.6.1
> $ mv lib/libgd.dll.a lib/libgd_dll.a
> $ mv mapogr.cpp mapogr.c

HTH

Norman





More information about the mapserver-users mailing list