Quick howto for compiling and running C# Mapscript (Linux)

Abe Gillespie agillesp at VT.EDU
Tue Jan 4 19:58:10 EST 2005


Prerequisites:
1.  An installed Mono
2.  A configured MapServer source tree

In the source tree you'll find \mapscript\csharp\Makefile; open it.
Two directories above that you'll see a file named mapscriptvars; open
it.  From the mapscriptvars file you'll need to copy the CCFLAGS and
LDFLAGS values to Makefile.  *Note - in mapscriptvars you won't see
"CCFLAGS=blah" or "LDFLAGS=blah" but the lines look something like:

-DIGNORE_MISSING_DATA -DNEED_STRLCAT -DUSE_EPPL -DUSE_TIFF -DUSE_GD_GIF
-DUSE_GD_PNG -DUSE_GD_JPEG -DUSE_GD_WBMP -DUSE_GD_FT
-DGD_HAS_GDIMAGEGIFPTR -DGD_HAS_GETBITMAPFONTS -DUSE_OGR -DUSE_GDAL

and

-L. -lmap -L/usr/src/gd-2.0.33/.libs -lgd -L/usr/src/jpeg-6b -ljpeg
-lfreetype -L/usr/src/libpng-1.2.5 -lpng -L/usr/src/zlib-1.2.1 -lz
-L/usr/src/tiff-v3.6.1/lib64 -ltiff -L/usr/src/jpeg-6b -ljpeg
-lfreetype -L/usr/src/libpng-1.2.5 -lpng -L/usr/src/zlib-1.2.1 -lz
-L/usr/src/jpeg-6b -ljpeg -L/usr/local/lib -lgdal -lc -lm

One thing I didn't have to do was copy over the include directories ...
so, if it works for you, ignore the line that looks something like:

-I. -I/usr/src/gd-2.0.33 -I/usr/src/tiff-v3.6.1/libtiff
-I/usr/src/jpeg-6b -I/usr/local/include

Ultimately your Makefile should look something like this:

.
.
.
CCFLAGS=-DIGNORE_MISSING_DATA -DNEED_STRLCAT -DUSE_EPPL -DUSE_TIFF
-DUSE_GD_GIF -DUSE_GD_PNG -DUSE_GD_JPEG -DUSE_GD_WBMP -DUSE_GD_FT
-DGD_HAS_GDIMAGEGIFPTR -DGD_HAS_GETBITMAPFONTS -DUSE_OGR -DUSE_GDAL

LDFLAGS=-L../.. -lmap -L/usr/src/gd-2.0.33/.libs -lgd
-L/usr/src/jpeg-6b -ljpeg -lfreetype -L/usr/src/libpng-1.2.5 -lpng
-L/usr/src/zlib-1.2.1 -lz -L/usr/src/tiff-v3.6.1/lib64 -ltiff
-L/usr/src/jpeg-6b -ljpeg -lfreetype -L/usr/src/libpng-1.2.5 -lpng
-L/usr/src/zlib-1.2.1 -lz -L/usr/src/jpeg-6b -ljpeg -L/usr/local/lib
-lgdal -lc -lm
.
.
.

Now run make.  If all went well you should have libmapscript.so and
mapscript_csharp.dll.  You can run a .Net exe (check the examples
directory) if you have these two files in the same directory.  If you
want them globally accessible copy mapscript_csharp.dll into the
mono/1.0 directory.  On my system it lives at /usr/local/lib/mono/1.0
Then you'll want to add a mapping to the mono/config file (make sure
you've put libmapscript.so in a useful place before doing so).  On my
system it lives at /usr/local/etc/mono  Add a line that looks something
like:

<dllmap dll="libmapscript" target="/usr/local/lib/libmapscript.so" />

Enjoy!

Has anyone had success doing this on Windows?

-Abe



More information about the mapserver-users mailing list