设为首页 收藏本站
查看: 1095|回复: 0

[经验分享] 如何编译mapserver在windows环境下(转载)

[复制链接]

尚未签到

发表于 2016-11-22 08:47:26 | 显示全部楼层 |阅读模式
编译mapserver的时候一定要选择一个根目录

推荐 C 盘

在C盘下面创建一个projects目录

将你的所以用来支持mapserver编译的支持库文件都放到该目录下面

注:由于mapserver等都是开源的软件。但是都有一定的版权。所以他们不是集成到mapserver下面的,而是有各种支持库文件通过编译说明文件链接

所有文件链接的说明文件在nmake.opt文件中。这是使用vc编译的说明文件。在编译的时候具体选择支持什么库文件都可以在这里说明。


下面是具体的编译环境

gdwin32 的bgd.lib是第一次编译后拷贝过来的运行makemsvcimport.bat
libpng 的libpng.lib,libpngd.lib是第一次编译后拷贝过来的vc6
freetype 的freetype2110_D.lib在vc7下面编译成功
zlib zlib.lib 编译成功在zlib123\contrib\vstudio\vc7用vc7
proj proj.lib 在vc7环境下编译成功
curl libcurl.lib 在vc6编译下成功 C:\projects\curl\lib
gdal gdal.lib 用submake.bat批处理文件执行编译成功
pdflib 用vc7编译成功 C:\projects\PDFlibLite

fcgi 没有成功 将fcgi_config_x86.h改为fcgi_config.h用vc6编译成功
jpeg 没有编译成功将gdal里的拷贝过来
regex 没有编译成功

编译支持库的时候比较艰难

仔细细心的查看各个支持库中的文档目录。一般都会有一个可以通过的编译。

编译的时候也要懂得使用技巧。比如他说找不到库文件或着什么头文件或源文件你都可以从其他地方拷贝一个过来。


附加nmake.opt文件的配置

#
# nmake.opt - MapServer 4.x configuration for MSVC++
#
# This VC++ configuration is used in building MAPSERVER.LIB, MAPSERV.EXE,
# and the other MapServer command-line programs.
#
# To use the makefile:
# - Open a DOS prompt window
# - Run the VCVARS32.BAT script to initialize the VC++ environment variables
# - Start the build with: nmake /f makefile.vc
#
# $Id: nmake.opt,v 1.24 2005/12/08 19:14:48 hobu Exp $
#
# Contents:
# Section I: Mapserver Options (you may want to edit)
# Section II: Support Libraries (you must edit)
# Section III: Debug Flags (no need to edit)
# Section IV: Variable Setup (should not need to edit)
# Section V: UMN GIS System Setup (should not need to edit)
# Section VI: Collect compiler flags
#
########################################################################
# Section I: Mapserver Options
########################################################################

# Uncomment the following to link mapserv.exe withh dll
DLLBUILD=1

# Set the following to point to the current directory.
MS_BASE = C:\projects\mapserver

# Optmization and related compile flags.

# Optimized, with using MSVCRT.
OPTFLAGS = /nologo /MD $(WARNING_LEVEL) $(DEBUG)

#LDFLAGS = /NODEFAULTLIB:msvcrt /NODEFAULTLIB:libcd /DEBUG

# Debug with MSVCRT
#OPTFLAGS = /nologo /Zi /MD $(WARNING_LEVEL) $(DEBUG)

# Optimized, with LIBC.
#OPTFLAGS = /nologo $(WARNING_LEVEL) $(DEBUG)

# Input raster format options:
#
# The lite version of mapserver 4.x supports only GIF, PNG and JPEG data for
# input. If you wish to support many geospatial raster formats for input
# you will need the GDAL support library from http://www.gdal.org/.
# Once built, enable the GDAL flag, and point GDAL_DIR to the directory
# where GDAL was built.
#GDAL=-DUSE_GDAL
#GDAL_DIR=c:\projects\gdal

#
# Input vector format options
#
# The lite version of Mapserver 4.x only suports ESRI shapefiles for input.
#
# The OGR library (part of GDAL) supports a variety of geospatial vector
# formats including mapinfo, Arc/Info binary coverages, S-57, SDTS,
# Microstation DGN (pre-v7), TIGER, UK .NTF. It also include support for
# treating non-spatial tablular data from ODBC, CSV, mysql, Oracle Spatial,
# and PostgreSQL as spatial table with use of the VRT (virtual) driver.
#
# NOTE: Both -DUSE_OGR and -DUSE_GDAL need to be defined if you want to
# use GDAL/OGR for both raster and vector support, but GDAL_DIR needs only
# be defined once.
#
#OGR=-DUSE_OGR
#GDAL_DIR=c:\projects\gdal

# JPEG Input:
# JPEG input for raster layers is also available through GDAL, If you wish
# to build support for JPEG without GDAL, uncomment the following flag
# and provide the full path to the jpeg support library project directory.
# See http://www.ijg.org/ for support library.
JPEG=-DUSE_JPEG
JPEG_DIR=c:/projects/libjpeg

# Output format options:
# If you wish to allow JPEG output maps, uncomment the following flag.
# If not using a GD build with an internal copy of libjpeg, you will
# also need to uncomment JPEG_DIR and point to it; however, with BGD.DLL
# that is not necessary.
OUTPUT_JPEG=-DUSE_GD_JPEG
JPEG_DIR=c:/projects/libjpeg

# If you wish to allow PNG output maps, uncomment the following flag.
# If not using a GD build with an internal copy of libpng, you will
# also need to uncomment PNG_DIR and ZLIB_DIR and point to it; however, with
# BGD.DLL that is not necessary.
# See http://www.libpng.org/pub/png/libpng.html for support library.
# See http://www.gzip.org/zlib/ for support library.
OUTPUT_PNG=-DUSE_GD_PNG

PNG_DIR=c:/projects/libpng

ZLIB_DIR=c:/projects/zlib

#flag to indicate the use of zlib library. It is used intially in SVG
#output to compressed files.
ZLIB=-DUSE_ZLIB

# If you wish to allow Windows BMP output maps, uncomment the following flag.
OUTPUT_WBMP=-DUSE_GD_WBMP

# If you wish to have FLASH output, uncomment the following flag and provide
# the full path to the MING support library project directory.
# See http://ming.sourceforge.net/ for support library.
#MING=-DUSE_MING_FLASH
#MING_DIR=c:/projects/ming-0.3beta1


# If you wish to have PDF output, uncomment the following flag and provide the
# full path to the PDF support library project directory.
# See http://www.pdflib.com/ for support library.
PDF=-DUSE_PDF
PDF_DIR=c:/projects/PDFlibLite


# Annotation fonts.
#
# If you wish to annotate your maps with true type fonts unccomment the
# following flag. Provide the full path to the FreeType 2.x external
# support library, unless it is provided within your GD build as is the
# case with BGD.DLL.
# See http://www.freetype.org for support library.
ANNOTATION_FT=-DUSE_GD_FT
FT_DIR=c:/projects/freetype


# Direct connectivity to Postgresql PostGIS.
#
# To turn on direct connectivity to Postgresql PostGIS uncomment the following
# flag and set the full path name to the project directory for the
# Postgresql native Win32 client library.
# See http://www.postgresql.org for support library.
#POSTGIS =-DUSE_POSTGIS
#POSTGIS_DIR =c:/projects/libpq

#Orcale
ORACLE_DIR = c:\Oracle\Ora81
ORACLE=-DUSE_ORACLESPATIAL

# Direct connectivity to ArcSDE.
#
# To turn on direct connectivity to ArcSDE uncomment the following
# flag and set the full path name to the project directory for ArcSDE.
# Since ESRI includes the version number in the name of their libraries
# you may need to change that number in Section III of this configuration
# file.
# See http://www.esri.com/software/arcgis...csde/index.html for
# support library
#
#
#SDE_OPT=-DUSE_SDE -DWIN32
#SDE_DIR=c:/my_path_to/arcsde

# EPPL7 Support
#
# This activates ERDAS as well. It is included in the distribution.
# Probably the best raster alternative if
# you've got EPPL7 laying around. See http://www.lmic.state.mn.us/ for
# more information.
# Uncomment out the following flag and set the full path name to the
# epplib.obj file.
#EPPL=-DUSE_EPPL
#EPPL_OBJ=c:/my_path/epplib.obj

# If you want to ignore missing datafile errors uncomment the following
# line. This is especially useful with large tiled datasets that may not
# have complete data for each tile.
IGNORE_MISSING_DATA=-DIGNORE_MISSING_DATA

# If you want to use shape Z and M parameter this option must be set.
# It's OFF by default.
#USE_POINT_Z_M=-DUSE_POINT_Z_M
USE_POINT_Z_M=

#NEED_NONBLOCKING_STDERR=-DNEED_NONBLOCKING_STDERR
ENABLE_STDERR_DEBUG=-DENABLE_STDERR_DEBUG

# If you want antialiasing (note that It requires gd2)
USE_GD_ANTIALIAS=-DUSE_GD_ANTIALIAS

# Enable if you want thread safe locking, not needed for simple CGI.
#THREADS=-DUSE_THREAD

# Use this flag to compile with WMS Server support.
# To find out more about the OpenGIS Web Map Server Specification go to
# http://www.opengis.org/
WMS=-DUSE_WMS_SVR

# Use this flag to compile with WMS Client support. WMS Client support
# allows you to pull layers from other OGIS WMS servers on the interent and
# incorporate them into your map.
# To find out more about the OpenGIS Web Map Server Specification go to
# http://www.opengis.org/
# you need the libcurl library from http://curl.haxx.se/library/c/
# Set the full path to the curl project directory.
# You may also need to the full path to the windows socket library.
#WMSCLIENT= -DUSE_WMS_LYR

CURL_DIR=c:/projects/curl
#CURL_DIR=c:/projects/curl-7.10.7
WINSOCK_LIB = "WSOCK32.LIB"
WINSOCK_LIB = "C:\Program Files\Microsoft Visual Studio\VC98\Lib\WSOCK32.LIB"

# Use -DUSE_WFS_SVR to compile with WFS server support, requires OGR and PROJ4
#WFS=-DUSE_WFS_SVR

# Use -DUSE_WFS_LYR to compile with WFS client support, requires libcurl
#WFSCLIENT= -DUSE_WFS_LYR

# Use -DUSE_WCS_SVR to compile with WCS server support, requires GDAL.
#WCS=-DUSE_WCS_SVR

#libiconv support is used for to support double bytes (see bug 911).
#uncomment the following to build with libiconv support.
#ICONV=-DUSE_ICONV
#

# Reprojecting.
# If you would like mapserver to be able to reproject data from one
# geographic projection to another, uncomment the following flag
# Proj.4 distribution (cartographic projection routines). PROJ.4 is
# also required for all OGC services (WMS, WFS, and WCS).
#
# For PROJ_DIR use full path to Proj.4 distribution
PROJ=-DUSE_PROJ -DUSE_PROJ_API_H
PROJ_DIR=c:\projects\proj

# PHP Mapscript.
# If you plan to build PHP mapscript uncomment the following flag and
# set the full path to the PHP project directory
#PHP=1
#PHP_DIR=c:\projects\php-4.3.4

# Apparently these aren't as commonplace. Edit the
# following line to reflect the missing functions on your platform.
#
#STRINGS=-DNEED_STRCASECMP -DNEED_STRNCASECMP -DNEED_STRDUP
STRINGS=-DNEED_STRCASECMP -DNEED_STRNCASECMP -DNEED_STRLCAT


########################################################################
# Section II: External Support Libraries
########################################################################
# You will need to set the paths to various support library projects
# that you have compiled.
########################################################################

# GD Library.
#
# Mapserver 4.x only supports GD 2.x and greater.
# Sorry no more GIF support. If you need GIF support you will
# need to run Mapserver 3.6.x with GD 1.2.
# GD is a required support library for MapServer 4.x.
# Enter the full path to your GD 2.x project directory

# Note : A patched version of GD that supports GIF, JPEG, PNG and WBMP can be
# downloaded from http://www.rime.com.au/gd/. If you are using this library,
#you should uncomment the following line
OUTPUT_GIF=-DUSE_GD_GIF -DGD_HAS_GDIMAGEGIFPTR

GD_DIR=c:/projects/gdwin32
GD_LIB=$(GD_DIR)/bgd.lib

#if the GD version you are using is above GD 2.0.22, uncomment the following flag to
#have a proper support for bitmap fonts (see Bug 969 for more details)
GD_HAS_GETBITMAPFONT=-DGD_HAS_GETBITMAPFONT

# REGEX Libary
#
# VC++ does not include the REGEX library... so we must provide our one.
# The following definitions will try to build GNU regex-0.12 located in the
# regex-0.12 sub-directory.
# If it was not included in the source distribution, then you can get it from:
# ftp://ftp.gnu.org/pub/gnu/regex/regex-0.12.tar.gz
# Provide the full path to the REGEX project directory
# You do not need this library if you are compiling for PHP mapscript.
# In that case the PHP regex library will be used instead
!IFNDEF PHP
REGEX_DIR=c:\projects\regex
!ENDIF

# FastCGI Support
#
# Uncomment, and update accordingly.
FCGIDIR=C:\projects\fcgi
FCGILIB=$(FCGIDIR)\libfcgi\Debug\libfcgi.lib
FCGIINC=-I$(FCGIDIR)\include
FCGIDEF=-DUSE_FASTCGI

########################################################################
# Section III: Debug flags
########################################################################
# Should not need to be updated.
########################################################################
# DEBUG Build flags
# Set the DEBUG flag if you wish to make a debug build
DEBUG=/DDEBUG
# Set the Warning level for the compiler (defaults to W1)
WARNING_LEVEL=/W3
# Set the linker debug option
LDEBUG=/debug


########################################################################
# Section IV: Variable Setup
########################################################################
# Should not need to be updated.
########################################################################

MS_LIB = mapserver.lib
MS_LIB_DLL = mapserver_i.lib

# Proj.4 include and library
!IFDEF PROJ_DIR
PROJ_INC=-I$(PROJ_DIR)/src
PROJ_LIB=$(PROJ_DIR)/src/proj_i.lib
!ENDIF

# CURL include and library
!IFDEF WMSCLIENT
CURL_INC = -I$(CURL_DIR)/include
CURL_LIB = $(CURL_DIR)/lib/libcurl.lib
!ENDIF

# Set the jpeg library
!IFDEF JPEG_DIR
JPEG_LIB=$(JPEG_DIR)/libjpeg.lib
!ENDIF

# Set the png support libaries
!IFDEF PNG_DIR
PNG_LIB=$(PNG_DIR)/libpng.lib $(ZLIB_DIR)/zlib.lib
!ENDIF

# Set the FreeType library
!IFDEF FT_DIR
#FT_LIB=$(FT_DIR)/objs/freetype211.lib
FT_LIB=$(FT_DIR)/objs/freetype211ST_D.lib
!ENDIF

# GD include and library
GD_INC= -I$(GD_DIR)
GD_LIBS= $(GD_DIR)/bgd.lib $(JPEG_LIB) $(PNG_LIB) $(FT_LIB)
GD= $(OUTPUT_PNG) $(OUTPUT_JPEG) $(OUTPUT_WBMP) $(OUTPUT_GIF) $(ANNOTATION_FT) $(GD_HAS_GETBITMAPFONT)

# Tiff library on input
!IFDEF TIFF
TIFF_INC=-I$(TIFF_DIR)/libtiff
TIFF_LIB=$(TIFF_DIR)/libtiff/libtiff.lib
!ENDIF

# JPEG library on input
!IFDEF JPEG_DIR
JPEG_LIB=$(JPEG_DIR)/libjpeg.lib
!ENDIF

# Setup GDAL includes and libraries
!IFDEF GDAL
GDAL_INC = -I$(GDAL_DIR)/gcore -I$(GDAL_DIR)/alg -I$(GDAL_DIR)/ogr -I$(GDAL_DIR)/port
GDAL_LIB = $(GDAL_DIR)/gdal_i.lib
!ENDIF

# Setup OGR includes and libraries
!IFDEF OGR
OGR_INC = -I$(GDAL_DIR)/ogr/ogrsf_frmts -I$(GDAL_DIR)/ogr -I$(GDAL_DIR)/port
OGR_LIB = $(GDAL_DIR)/gdal_i.lib
!ENDIF

# Setup ESRI SDE support.
!IFDEF SDE_OPT
SDE_INC=-I$(SDE_DIR)/include
SDE_LIB=$(SDE_DIR)/lib/sde80.lib $(SDE_DIR)/lib/sg80.lib $(SDE_DIR)/lib/pe80.lib
!ENDIF

# Setup REGEX object and includes
!IFNDEF PHP
REGEX_OBJ=$(REGEX_DIR)\regex.obj
REGEX_INC=-I$(REGEX_DIR)
!ELSE
REGEX_OBJ=$(PHP_DIR)\regex\regcomp.obj $(PHP_DIR)\regex\regerror.obj \
$(PHP_DIR)\regex\regexec.obj $(PHP_DIR)\regex\regfree.obj
REGEX_INC=-I$(PHP_DIR)/regex -DPHP_NO_ALIASES
!ENDIF
#
# REGEX needs some special flags... here they are for VC++ 6.0
#
REGEX_OPT=-DHAVE_STRING_H -DREGEX_MALLOC

# Setup Postgesql PostGIS includes and libs
# Note that the Postgresql includes are not used in the compilation of
# PHP/MapScript. The reason is that there is a name conflict between the
# regex/regex.h files used in PHP and Postgresql. This is not a real issue
# since they are two completely different interfaces. The issue arrises when
# the php_regex.h trys to include regex/regex.h and gets the wrong one from
# postgresql. Therefore we do not give it that opertunity by not providing the
# include path.
!IFDEF POSTGIS
!IFNDEF PHP_BUILD_CALL
#POSTGIS_INC=-I$(POSTGIS_DIR)/src/interfaces/libpq -I$(POSTGIS_DIR)/src/include
POSTGIS_INC=-I$(POSTGIS_DIR)/interfaces/libpq -I$(POSTGIS_DIR)/include
!ENDIF
#POSTGIS_LIB=$(POSTGIS_DIR)/src/interfaces/libpq/release/libpqdll.lib
POSTGIS_LIB=$(POSTGIS_DIR)/interfaces/libpq/libpqdll.lib

POSTGIS_OBJ=mappostgis.obj
!ENDIF

# Setup FLASH includes and libs
!IFDEF MING
MING_INC=-I$(MING_DIR)/src -I$(MING_DIR)
MING_LIB= $(MING_DIR)/src/libming.lib
#MING_VERSION=-DMING_VERSION_03
!ENDIF

# Setup PDF includes and libs
!IFDEF PDF
PDF_LIB=$(PDF_DIR)/pdflib/pdflib.lib
PDF_INC=-I$(PDF_DIR)/pdflib
!ENDIF

#Oracle support
!IFDEF ORACLE
ORACLE_INC=-I$(ORACLE_DIR)/oci/include
ORACLE_LIB=$(ORACLE_DIR)/oci/lib/msvc/oci.lib
!ENDIF

#libiconv support
!IFDEF ICONV
ICONV_LIB=c:\usr\lib\iconv.lib
ICONV_INC= -Ic:\usr\include
!ENDIF


########################################################################
# Section V: UMN GIS System Support
########################################################################
# Should not need to be updated.
########################################################################
#
# UofMN GIS/Image Processing Extension (very experimental)
#
#EGIS=-DUSE_EGIS

!IFDEF EGIS
ERR_DIR=c:/my_path_to/errLog
ERR_OBJ=$(ERR_DIR)/errLog.o
ERR_INC=-I$(ERR_DIR)
ERR_LIB=-L$(ERR_DIR) -lerrLog

IMGGEN_DIR=c:/my_path_to/imgSrc
IMGGEN_OBJ=$(IMGGEN_DIR)/imgLib.o
IMGGEN_INC=-I$(IMGGEN_DIR)
IMGGEN_LIB=-L$(IMGGEN_DIR) -limgGEN
!ENDIF

########################################################################
# Section VI: Collect compiler flags
########################################################################
# Should not need to be updated.
########################################################################
EXTERNAL_LIBS=$(GD_LIBS) $(TIFF_LIB) $(JPEG_LIB) \
$(PROJ_LIB) $(OGR_LIB) $(GDAL_LIB)\
$(CURL_LIB) $(MING_LIB) $(PDF_LIB) \
$(WINSOCK_LIB) $(POSTGIS_LIB) $(IMGGEN_LIB) $(ERR_LIB) \
$(ORACLE_LIB) $(SDE_LIB) $(ICONV_LIB) $(FCGILIB)

LIBS=$(MS_LIB) $(EXTERNAL_LIBS)
LIBS_DLL=$(MS_LIB_DLL) $(EXTERNAL_LIBS)

INCLUDES=$(GD_INC) $(TIFF_INC) $(JPEG_INC) \
$(PROJ_INC) $(REGEX_INC) $(GDAL_INC) $(OGR_INC) \
$(CURL_INC) $(MING_INC) $(PDF_INC) $(POSTGIS_INC) \
$(IMGGEN_INC) $(ERR_INC) $(ORACLE_INC) $(SDE_INC)\
$(ICONV_INC) $(FCGIINC)


MS_DEFS = $(REGEX_OPT) $(STRINGS) $(POSTGIS) -DWIN32 -D_WIN32 \
$(EPPL) $(PROJ) $(TIFF) $(JPEG) $(GD) $(OGR) $(WMS) $(THREADS) \
$(WMSCLIENT) $(MING) $(IGNORE_MISSING_DATA) $(NEED_NONBLOCKING_STDERR) $(ENABLE_STDERR_DEBUG) \
$(USE_POINT_Z_M) $(GDAL) $(FCGIDEF) \
$(WFS) $(WFSCLIENT) $(WCS) $(PDF) $(EGIS) \
$(USE_GD_ANTIALIAS) $(ORACLE) $(MING_VERSION) $(SDE_OPT) $(ICONV)

MS_CFLAGS=$(INCLUDES) $(MS_DEFS)



附加英文的mapserver编译文档

Win32 Compilation and Installation

Document Actions



This document provides a simple set of compilation procedures for MapServer on Win32 platforms.
Table of Contents

Introduction
Compiling
Set up a Project Directory
Download MapServer Source Code and Supporting Libraries
The MapServer source code
Set Compilation Options
Compile the Libraries
Compile MapServer
Common Compiling Errors
Installation
Other Helpful Information
About This Document
Copyright Information
Disclaimer
Acknowledgements
Feedback
Introduction

If you've made it this far, chances are you already know about MapServer and are at least tempted to try compiling it for yourself. If you've never heard of MapServer before or what it does, then may I suggest going to its web site at http://mapserver.gis.umn.edu.

Pre-compiled binaries for MapServer are available from a variety of sources. Refer to http://mapserver.gis.umn.edu/win32binaries.html. Building MapServer for win32 platforms can be a daunting task, so if existing binaries are sufficient for your needs, it is strongly advised that they be used in preference to trying to build everything from source.

However, there can be a variety of reasons to want to build MapServer from source on win32. Reasons include the need to enable specific options, to build with alternate versions of support libraries (such as GDAL), the desire for MapScript support not part of the core builds, the need to debug and fix bugs or even to implement new features in MapServer. To make it easy for users and developers, I've made a list of steps to compile MapServer. Background information is provided in each step, along with examples. Each example is a continuation of the previous one and in the end will produce the MapServer DLL (libmap.dll), the CGI program (the mapserv.exe), and utility programs.

Compiling
If you are new to Windows programming, please follow this document carefully. The compilation steps are fairly simple but I've added a few blurbs in each step to help you understand how MapServer compiles. For the more experienced programmers, perhaps reading the README.Win32 that accompanies the MapServer source code would be more useful. For those who are antsy, compiling MapServer involves download and unpacking the source codes, editing the make files, and invoking Microsoft's Visual C++ compiler from the command prompt. The resulting mapserv.exe is the CGI program that installs in the cgi-bin directory of your web server.

For those who are willing to take the time, the compilation steps follow.

Set up a Project Directory
Before you start to compile MapServer, I recommend creating a directory called "projects" where you can put the source code for MapServer and its supporting libraries. Since you will be working with DOS-style commands, you might as well get used to the Windows command prompt. For Windows 95/98 users the command processor would be called command.com. For Windows NT/2000/XP, it would be cmd.exe. So fire up the old command prompt and go to the drive where you want to create the project directory.

Here is an example of how to create a directory called projects on the C: drive:

C:\Users>mkdir C:\Projects
To go to that directory:

C:\Users> cd \ProjectsC:\Projects>
From the projects directory, you can extract the source codes for MapServer and its libraries. Now you're ready to download the source codes.

Download MapServer Source Code and Supporting Libraries
After creating a project directory, download the MapServer source code and the codes for the supporting libraries and save the source code packages in the newly created "projects" directory. These source codes are usually packaged as ZIP, or as UNIX TAR and GZIP files. You'll need a software that can unzip these packages. WinZIP is an example of software that can handle these files. Cygwin is a free, open-source software package which is a port of these tools on Windows. You can use the gzip and tar utilities from this tool collection. Cygwin is available from http://www.cygwin.com.

In order to compile the MapServer CGI program, you must download a few required and optional libraries. At its simplest configuration, MapServer only requires the GD (to provide the image output) and REGEX (to provide regular expression support) libraries. This configuration allows the developer/data provider to use shapefiles as input and, depending on the version of GD library used, GIF or PNG images as output. Additional libraries are needed for input data in alternative formats. The libraries that work with MapServer are listed below.

The MapServer source code
The MapServer source code can be downloaded from http://mapserver.gis.umn.edu/dload.html. If you'd like to get the current development version of the software, following the nightly snapshot link under the Interim Builds title. The absolute latest copy of the source code can be obtained from CVS; however, the CVS respository does not contain several important source files (maplexer.c, mapparser.c and mapparser.h) normally generated on unix, so if possible, using a nightly snaphot is substantially easier than working directly from CVS.

Required Libraries

GD Library :
MapServer uses the GD graphics library for rendering map images in GIF, PNG and JPEG format. These map images are displayed in web browser clients using the MapServer CGI. The current official version of GD is 2.0.33. The distributed makefiles are setup to use the prebuilt GD Win32 DLL binaries which include GD, libjpeg, libpng, libz, libgif and FreeType 2 all within one DLL. This package is generally listed as "Windows DLL .zip" and the latest version is normally available at http://www.boutell.com/gd/http/gdwin32.zip.

Regex:
Regex is the regular expression library used by MapServer. It can be downloaded at ftp://ftp.gnu.org/pub/gnu/regex/regex-0.12.tar.gz.

Optional Libraries

JPEG library:
This library is required by GD to render JPEG images, if building GD from source. You may download this library at http://www.ijg.org/files/jpegsrc.v6b.tar.gz.

PNG library:
This library is required by GD to render PNG images, if building GD from source. You may download this library at http://sourceforge.net/projects/libpng/.

Zlib:
This library is required by libpng to provide graphics compression support. It can be downloaded along with the PNG library, or at http://www.gzip.org/zlib.zip.

FreeType 2:
FreeType provides TrueType support in MapServer via GD. We only need to build FreeType seperately if building GD from source. It can be downloaded at ftp://freetype.sourceforge.net/pub/freetype/freetype2/. The most current version is 2.1.9.

PROJ.4:
Proj.4 provides on-the-fly projection support to MapServer. Users whose data are in different projection systems can use this library to reproject into a common projection. It is also required for WMS, WFS or WCS services. The current version is 4.4.9 and can be downloaded at ftp://ftp.remotesensing.org/pub/proj/proj-4.4.9.zip.

GDAL/OGR:
The GDAL/OGR library allows MapServer to read a variety of geospatial raster formast (GDAL) and vector formats (OGR). It can be downloaded at http://www.gdal.org/dl/. The 1.2.5 version is known to work well with MapServer 4.4.

ArcSDE:
ArcSDE is an ESRI proprietary spatial database engine. Most users will not have access to it but if you have ArcSDE license, you can use its libraries to give MapServer access to SDE databases.

EPPL7:
This library allows MapServer to read EPPL7 datasets, as well as the older Erdas LAN/GIS files. This library is set as a default library in MapServer so there's no special source code to download.

Now that you have reviewed the libraries that provide support to MapServer, it is time to decide which ones to compile and use. We will work with the pre-built GD distributed on Boutell.com with PNG, GIF, JPEG, and FreeType "built in". If you want to provide OGC Web Services (ie. WMS, WFS) or want to perform on the fly reprojection then the PROJ.4 library will be needed. If you need additional raster and vector data sources consider including GDAL/OGR support. GDAL is also required for WCS service.

Our example calls for the required libraries and on-the-fly projection support so we need to download GD, regex, and Proj.4 libraries. Go ahead and get those libraries.

Set Compilation Options
MapServer, like many of it's support libraries, comes with a Visual C++ makefile called Makefile.vc. It includes the file nmake.opt which contains many of the site specific definitions. We will only need to edit the nmake.opt file to configure the build for our local site options, and support libraries. The Makefile.vc, and nmake.opt template file have been provided by Assefa Yewondwossen, and the DM Solutions folks.

As of MapServer 4.4, the default MapServer build options only include GD, and regex. MapServer is built using the /MD option (which means MSVCRT.DLL should be used), so if any support libraries are being built statically (rather than as DLLs) we need to use /MD when building them as well. By default modern PROJ.4 builds use /MD so we should be able to use the default PROJ.4 build without tweaking.

The example will compile with the GDWin32 pre-built DLL as well as regex-0.12, and PROJ.4. The PROJ.4 support will ensure we can enable MapServer OGC-WMS compatibility. Use notepad or another text editor to open the nmake.opt file and make the following changes.

Comments
Use the pound sign ( # ) to comment out the lines that you want to disable, or remove the pound sign to enable an option for NMAKE.

A. Enable PROJ.4 support, and update the path to the PROJ.4 directory. Uncomment the PROJ= line, and the PROJ_DIR= line as follows, and update the PROJ_DIR path to point to your PROJ build.

# Reprojecting.# If you would like mapserver to be able to reproject data from one# geographic projection to another, uncomment the following flag# Proj.4 distribution (cartographic projection routines). PROJ.4 is# also required for all OGC services (WMS, WFS, and WCS). ## For PROJ_DIR use full path to Proj.4 distributionPROJ=-DUSE_PROJ -DUSE_PROJ_API_HPROJ_DIR=c:\projects\proj-4.4.9
If you look down later in the file, you can see that once PROJ is enabled, MapServer will be linked with proj_i.lib, the PROJ.4 stub library, meaning that MapServer will be using the PROJ.DLL as opposed to statically linking in PROJ.4.

B. Uncomment the WMS option.

# Use this flag to compile with WMS Server support.# To find out more about the OpenGIS Web Map Server Specification go to# http://www.opengis.org/WMS=-DUSE_WMS_SVR

C. Update to use GD. Here's what it should look like in our example.

GD_DIR=c:/projects/gdwin32GD_LIB=$(GD_DIR)/bgd.lib

Note
As distributed the GDWin32 binary build does not include the bgd.lib stub library. It is necessary to run the makemsvcimport.bat script in the gdwin32 directory first.

D. Make sure the regex path is set correctly. In order for the "delete" command in the "nmake /f makefile.vc clean" target to work properly it is necessary to use backslashes in the REGEX_DIR definition.

# REGEX Libary# # VC++ does not include the REGEX library... so we must provide our one.# The following definitions will try to build GNU regex-0.12 located in the# regex-0.12 sub-directory.# If it was not included in the source distribution, then you can get it from:# ftp://ftp.gnu.org/pub/gnu/regex/regex-0.12.tar.gz# Provide the full path to the REGEX project directory# You do not need this library if you are compiling for PHP mapscript.# In that case the PHP regex library will be used instead!IFNDEF PHPREGEX_DIR=c:\projects\regex-0.12!ENDIF

Your Makefile is now set.

Compile the Libraries
Before compiling MapServer, you must first compile its supporting libraries. How this is done varies for each library. For the PROJ.4 library a nmake /f makefile.vc command in the proj-4.4.9\src directory should be sufficient. The regex-0.12 code is actually built by the MapServer build process, so you don't need to do anything there.

Note: Compiling libcurl

Previously, curl libraries can be compiled using the following command:

nmake /f makefile.vc6 CFG=release
This creates a static library, libcurl.lib, to which you compile against. Versions newer than version 7.10.x should be compiled as dynamic library. This is accomplished using the command:
nmake /f makefile.vc6 CFG=release-dll
You will then need to edit MapServer's nmake.opt to replace the CURL_LIB variable with this line:
CURL_LIB = $(CURL_DIR)/lib/libcurl_imp.lib

Compile MapServer
Once you have compiled the supporting libraries successfully, you are ready to take the final compilation step. If you have not already done so, open a command prompt and set the VC++ environment variables by running the vcvars32.bat usually located in C:\Program Files\Microsoft Visual Studio\VC98\bin\vcvars32.bat.

C:\Users>cd \projects\mapserverC:\Projects\mapserver>"C:\Program Files\Microsoft Visual Studio\VC98\Bin\vcvars32.bat"C:\Projects\mapserver>Setting environment for using Microsoft Visual C++ tool.C:\Projects\mapserver>

Now issue the command: nmake /f Makefile.vc and wait for it to finish compiling. If it compiles successfully, you should get mapserver.lib, libmap.dll, mapserv.exe, and other .EXE files. That's it for the compilation process. If you run into problems, read section 4 about compiling errors. You can also ask for help from the helpful folks in the MapServer-dev e-mail list.

Compiling MapServer with PostGIS support

To compile PostGIS support into MapServer, here's what you need to do:

1. download the PostgreSQL 8.0.1 sources (postgresql-8.0.1.tar.gz) eg from:
ftp://ftp.heanet.ie/pub/postgresql/...ql-8.0.1.tar.gz
2. I extracted them to C:\projects\postgresql-8.0.1
3. download the Microsoft Platform SDK (250 Mb!) from
http://www.microsoft.com/msdownload...msdk/sdkupdate/
otherwise you get link errors on shfolder.lib.
4. compile libpq under C:\projects\postgresql-8.0.1\src\interfaces\libpq
using the win32.mak makefile
5. copy everything from C:\projects\postgresql-8.0.1\src\interfaces\libpq\release
to C:\projects\postgresql-8.0.1\src\interfaces\libpq as the Mapserver
makefile will try to find it there
6. Define the following in the nmake.opt for Mapserver:
POSTGIS =-DUSE_POSTGIS
POSTGIS_DIR =c:/projects/postgresql-8.0.1/src
7. nmake /f makefile.vc
8. don't forget to copy libpq.dll (from
C:\projects\postgresql-8.0.1\src\interfaces\libpq\release)
into a location where Mapserver can find it.


Common Compiling Errors
Following are a few common errors you may encounter while trying to build MapServer.

Visual C++ Tools Not Properly Initialized.

C:\projects\mapserver>nmake -f /makefile.vc'nmake' is not recognized as an internal or external command,operable program or batch file.
This occurs if you have not properly defined the path and other environment variables required to use MS VisualC++ from the command shell. Invoke the VCVARS32.BAT script, usually with the command C:\Program Files\Microsoft Visual Studio\VC98\bin\vcvars32.bat or something similar if visual studio was installed in an alternate location. To test if VC++ is available, just type "nmake" or "cl" in the command shell and ensure it is found.

Regex Build Problems.

regex.obj : error LNK2001: unresolved external symbol _printcharlibmap.dll : fatal error LNK1120: 1 unresolved externalsNMAKE : fatal error U1077: 'link' : return code '0x460'Stop.
This occurs if you use the stock regex-0.12 we referenced. I work around this by commenting out the "extern" statement for the printchar() function, and replacing it with a stub implementation in regex-0.12\regex.c.
//extern void printchar ();void printchar( int i ) {}

GD Import Library Missing.

LINK : fatal error LNK1104: cannot open file 'c:/projects/gdwin32/bgd.lib'NMAKE : fatal error U1077: 'link' : return code '0x450'Stop.
If you are using the pre-built GD binaries, you still need to run the makemsvcimport.bat script in the gdwin32 directory to create a VC++ compatible stub library (bgd.lib).

Installation
The file we are most interested in is mapserv.exe. The other executable files are the MapServer utility programs. Visit the MapServer utility page at http://mapserver.gis.umn.edu/utils.html to learn more about these utilities.

To test that the CGI program is working, type mapserv.exe at the command prompt. You should see the following message:

This script can only be used to decode form results andshould be initiated as a CGI process via a httpd server.

You may instead get a popup indicating that a DLL (such as bgd.dll) is missing. You will need to copy all the required DLLs (ie. bgd.dll, and proj.dll) to the same directory as the mapserv.exe program.

Now type mapserv -v at the command prompt to get this message:

MapServer version 4.4.0-beta3 OUTPUT=GIF OUTPUT=PNG OUTPUT=JPEG OUTPUT=WBMP SUPPORTS=PROJ SUPPORTS=FREETYPE SUPPORTS=WMS_SERVER INPUT=SHAPEFILE DEBUG=MSDEBUG

This tells us what data formats and other options are supported by mapserv.exe. Assuming you have your web server set up, copy mapserv.exe, libmap.dll, bgd.dll, proj.dll and any other required DLLs to the cgi-bin directory.

You are now ready to download the demo application and try out your own MapServer CGI program. If you wish, you can also create a directory to store the utility programs. I'd suggest making a subdirectory called "bin" under the directory "projects" and copy the executables to that subdirectory. You might find these programs useful as you develop MapServer applications.

Other Helpful Information
The MapServer Unix Compilation and Installation HOWTO has good descriptions of some MapServer compilation options and library issues. I will write more about those options and issues on the next revision of this HOWTO.

The README documents of each of the supporting libraries provide compilation instructions for Windows.

The MapServer User community has a collective knowledge of the nuances of MapServer compilation. Seek their advice wisely.

About This Document
Copyright Information
Copyright (c) 2001, Pericles S. Nacionales, University of Minnesota

This documentation is covered by the same Open Source license as the MapServer software itself. See MapServer's License and Credits page for the complete text.

Disclaimer
No liability for the contents of this document can be accepted. Use the concepts, examples and other content at your own risk. As this is a new edition of this document, there may be errors and inaccuracies that may be damaging to your system. Although this is highly unlikely, the author(s) do not take any responsibility for that: proceed with caution.

Acknowledgements
Thanks to Assefa Yewondwossen for providing the Makefile.vc. I would not have been able to write this HOWTO without that file.

Thanks to Bart van den Eijnden for the libcurl and PostGIS compilation info.

Thanks to the Steve Lime for developing MapServer and to the many developers who contribute time and effort in order to keep the MapServer project successful.

This How-to applies to: MapServer 4.6, MapServer 4.8

运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-303762-1-1.html 上篇帖子: Silverlight与常用数据库互操作系列索引 下篇帖子: 如何处理大量数据
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表