Building MapGuide on Windows

This is a working document which attempts to describe how to build
MapGuide Open Source from the latest SVN source on Windows.
This initial version is based on my initial experience, contains errors, and some lazyness. You may find that the FDO build instructions are better than these for the FDO portion of the build. 
Jasonbirch 07:53, 10 November 2006 (CET)
=Prerequisites=
These prerequisites are based on the structure that was used, and may require adjustment for your environment.
Some requirements may not be strictly be required if all you are doing is building a "Release" version of MapGuide Open Source and not doing the unit tests or building the documentation. A knowledgeable user may be able to pare down this list. More information is available in the official build documentation at: and . This document varies from these instructions considerably.
==Directory Structure==
The examples in this document assume that your working directory is:
 D:\OSGeo\
and that you have the following directories created under that location:
 D:\OSGeo\FDOBuild
 D:\OSGeo\FDODev
 D:\OSGeo\MGBuild
 D:\OSGeo\MGDev
 D:\OSGeo\MGPkg optional
==Applications==
The following applications should be installed in their default locations unless otherwise noted.
* Microsoft Visual Studio (Professional works, not sure what the requirement is. FDO on its own is known to build with the Express versions)
* Microsoft Windows Server 2003 R2 Platform SDK 
* SVN Commandline Client - get the latest version with a -setup extension. You might also like TortoiseSvn as a GUI for other SVN tasks.
* ActiveState Perl
* Sun J2SE/JDK
* MySQL Developer and Client tools - This is the full server isntall, but you can choose to only install the client and developer components without the database engine.
The original author is thinks that these are probably optional - if you don't install them, make sure you adjust the environment variables to suit
* GNUWin32 - it is recommended to use the GetGNUWin32 utility to download and install at least Bison and Sed. However, you don't need to stop there. The original author find uses for "find", "grep", "xargs", and many other utilities on a daily basis. It gives your Windows environment much of the power of a Unix shell.
* Doxygen Documentation Tool
* GraphViz Graphing Tool
* Microsoft HTML Help Workshop
==Environment Variables==
These are specific to the original author's environment and will likely need modification.
 JAVA_HOME={YourJdkInstallationPath}
 BUILD_ROOT=D:\OSGeo
 FDO=%BUILD_ROOT%\FDOBuild\fdo
 FDOBUILD=%BUILD_ROOT%\FDOBuild
 FDOMYSQL=C:\Program Files\MySQL\MySQL Server 5.0
 FDOTHIRDPARTY=%BUILD_ROOT%\FDOBuild\Thirdparty
 FDOUTILITIES=%BUILD_ROOT%\FDOBuild\Utilities
 FDO_SVN_ROOT=%BUILD_ROOT%\FDODev
 GDAL_DATA=%BUILD_ROOT%\MGBuild\Oem\gdal-1.3.0\data
 MGBUILD=%BUILD_ROOT%\MGBuild
 NLSDIR=%BUILD_ROOT%\FDOBuild\Thirdparty\apache\xml-xalan\c\Src\xalanc\NLS
 PATH=%PATH%;C:\Program Files\Subversion\bin;C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727;C:\Program Files\Microsoft Visual Studio 8\Common7\IDE;C:\Program Files\7-Zip;C:\Program Files\ATT\Graphviz\bin;C:\Program Files\doxygen\bin;C:\Program Files\GnuWin32\bin;C:\Perl\bin;%JAVA_HOME%\bin
 PROJ_LIB=%BUILD_ROOT%\MGBuild\Oem\proj-4.4.9\nad
 XALANROOT=%BUILD_ROOT%\FDOBuild\Thirdparty\apache\xml-xalan\c
 XERCESCROOT=%BUILD_ROOT%\FDOBuild\Thirdparty\apache\xml-xerces\c
==Configuration==
Visual Studio will need to have some paths set up. Go to:
 Tools->Options->"Projects & Solutions"->"VC++ Directories"
When showing directories for "executable files", add the following:
 {YourJdkInstallPath}/bin
When showing directories for "include files", add the following:
 {YourJdkInstallPath}/include
 {YourJdkInstallPath}/include/Win32
==ArcSDE==
The original author does not have ArcSDE SDK available. Hopefully instructions that include this provider will be created at some point. In the meantime, refer to the FDO build docs for clues.
=Initial SVN Checkout=
This takes quite a while the first time, and should probably be batched.
 svn checkout https://fdocore.osgeo.org/svn/fdocore/trunk/Fdo "D:\OSGeo\FDODev" --username myOSGeoUsername --password myOSGeoPassword
 svn checkout https://fdocore.osgeo.org/svn/fdocore/trunk/Thirdparty "D:\OSGeo\FDODev\Thirdparty" --username myOSGeoUsername --password myOSGeoPassword
 svn checkout https://fdocore.osgeo.org/svn/fdocore/trunk/Utilities "D:\OSGeo\FDODev\Utilities" --username myOSGeoUsername --password myOSGeoPassword
 svn checkout https://fdocore.osgeo.org/svn/fdocore/trunk -N "D:\OSGeo\FDODev" --username myOSGeoUsername --password myOSGeoPassword
 svn checkout https://fdoshp.osgeo.org/svn/fdoshp/trunk/Providers/SHP "D:\OSGeo\FDODev\Providers\SHP" --username myOSGeoUsername --password myOSGeoPassword
 svn checkout https://fdosdf.osgeo.org/svn/fdosdf/trunk/Providers/SDF "D:\OSGeo\FDODev\Providers\SDF" --username myOSGeoUsername --password myOSGeoPassword
 svn checkout https://fdowfs.osgeo.org/svn/fdowfs/trunk/Providers/WFS "D:\OSGeo\FDODev\Providers\WFS" --username myOSGeoUsername --password myOSGeoPassword
 svn checkout https://fdowms.osgeo.org/svn/fdowms/trunk/Providers/WMS "D:\OSGeo\FDODev\Providers\WMS" --username myOSGeoUsername --password myOSGeoPassword
 svn checkout https://fdoarcsde.osgeo.org/svn/fdoarcsde/trunk/Providers/ArcSDE "D:\OSGeo\FDODev\Providers\ArcSDE" --username myOSGeoUsername --password myOSGeoPassword
 svn checkout https://fdordbms.osgeo.org/svn/fdordbms/trunk/Providers/GenericRdbms "D:\OSGeo\FDODev\Providers\GenericRdbms" --username myOSGeoUsername --password myOSGeoPassword
 svn checkout https://fdogdal.osgeo.org/svn/fdogdal/trunk/Providers/GDAL "D:\OSGeo\FDODev\Providers\GDAL" --username myOSGeoUsername --password myOSGeoPassword
 svn checkout https://fdogdal.osgeo.org/svn/fdogdal/trunk/Providers/GDAL "D:\OSGeo\FDODev\Providers\GDAL" --username myOSGeoUsername --password myOSGeoPassword
 svn checkout https://mapguide.osgeo.org/svn/mapguide/trunk/MgDev "D:\OSGeo\MGDev" --username myOSGeoUsername --password myOSGeoPassword
After the first checkout these can be done with an "update". Actually I think the first checkout can too...
=Copy to a Clean Build Area=
The svn "export" command allows you to make a nice clean copy to build in. 
 del /Q D:\OSGeo\FDOBuild\*
 svn export --force "D:\OSGeo\FDODev" "D:\OSGeo\FDOBuild"
 
 rd /S /Q D:\OSGeo\FDOBuild\Thirdparty
 svn export "D:\OSGeo\FDODev\Thirdparty" "D:\OSGeo\FDOBuild\Thirdparty"
 
 rd /S /Q D:\OSGeo\FDOBuild\Fdo
 svn export "D:\OSGeo\FDODev\Fdo" "D:\OSGeo\FDOBuild\Fdo"
 
 rd /S /Q D:\OSGeo\FDOBuild\Utilities
 svn export "D:\OSGeo\FDODev\Utilities" "D:\OSGeo\FDOBuild\Utilities"
 
 rd /S /Q D:\OSGeo\FDOBuild\Providers
 mkdir D:\OSGeo\FDOBuild\Providers
 svn export "D:\OSGeo\FDODev\Providers\SHP" "D:\OSGeo\FDOBuild\Providers\SHP"
 svn export "D:\OSGeo\FDODev\Providers\SDF" "D:\OSGeo\FDOBuild\Providers\SDF"
 svn export "D:\OSGeo\FDODev\Providers\WFS" "D:\OSGeo\FDOBuild\Providers\WFS"
 svn export "D:\OSGeo\FDODev\Providers\WMS" "D:\OSGeo\FDOBuild\Providers\WMS"
 svn export "D:\OSGeo\FDODev\Providers\GDAL" "D:\OSGeo\FDOBuild\Providers\GDAL"
 
 svn export "D:\OSGeo\FDODev\Providers\GenericRdbms" "D:\OSGeo\FDOBuild\Providers\GenericRdbms"
 
 REM Don't have the ArcSDE SDK files...
 REM svn export "D:\OSGeo\FDODev\Providers\ArcSDE" "D:\OSGeo\FDOBuild\Providers\ArcSDE"
 
 rd /S /Q D:\OSGeo\MGBuild
 svn export "D:\OSGeo\MGDev" "D:\OSGeo\MGBuild" 
=Build FDO Thirdparty=
The FDO build complains if some of the environment variables which are required for MapGuide are set when it's built (because those components aren't compiled yet). What you can do to work around this is to create a batchfile in the D:\OSGeo directory with the following contents and use it to build the third party components.
 @echo off
 
 SET OLD_GDAL_DATA=%GDAL_DATA%
 SET GDAL_DATA=
 SET OLD_PROJ_LIB=%PROJ_LIB%
 SET PROJ_LIB=
 
 pushd %FDOBUILD%
 call build_thirdparty.bat
 popd
 
 SET GDAL_DATA=%OLD_GDAL_DATA%
 SET OLD_GDAL_DATA=
 SET PROJ_LIB=%OLD_PROJ_LIB%
 SET OLD_PROJ_LIB=
=Build FDO=
The same logic applies here.
 @echo off
 
 SET OLD_GDAL_DATA=%GDAL_DATA%
 SET GDAL_DATA=
 SET OLD_PROJ_LIB=%PROJ_LIB%
 SET PROJ_LIB=
 
 pushd %FDOBUILD%
 call build.bat
 popd
 
 SET GDAL_DATA=%OLD_GDAL_DATA%
 SET OLD_GDAL_DATA=
 SET PROJ_LIB=%OLD_PROJ_LIB%
 SET OLD_PROJ_LIB=
=Install FDO into the MapGuide Build Area=
This batch file installs both the required third party libraries and the compiled common FDO components and providers into the MapGuide build area
 @echo off
 
 SET OLD_GDAL_DATA=%GDAL_DATA%
 SET GDAL_DATA=
 SET OLD_PROJ_LIB=%PROJ_LIB%
 SET PROJ_LIB=
 
 pushd %FDOBUILD%
 call build.bat -a=install -o=D:\OSGeo\MGBuild\Oem
 popd
 
 pushd %FDOBUILD%
 call build_thirdparty.bat -a=install -o=D:\OSGeo\MGBuild\Oem
 popd
 
 SET GDAL_DATA=%OLD_GDAL_DATA%
 SET OLD_GDAL_DATA=
 SET PROJ_LIB=%OLD_PROJ_LIB%
 SET OLD_PROJ_LIB=
When this is done, go to the FDO directory and edit the providers.xml file so that it no longer contains the path to the providers. If you don't do this, you will have to fix every installation that you make from this source.
=Compile MapGuide=
This is the fun part. Make sure to either compile all of the components in Debug mode or all of them in Release mode. Do not mix and match.
For each of the following, open it in Visual Studio, compile it, and close.
 D:\OSGeo\MGBuild\OEM\oem.sln
 D:\OSGeo\MGBuild\Oem\fcgi\fcgi-2.4.0\Win32\FastCGI.sln
 D:\OSGeo\MGBuild\Oem\fcgi\isapi\FcgiWin.sln
 D:\OSGeo\MGBuild\Server\Server.sln
 D:\OSGeo\MGBuild\Web\src\WebTier.sln
Now we're cooking with gas :)
Note that the serverconfig.ini file uses paths relative to the server bin directory for repositories, packages, etc. If you are saving yourself some work and installing this build into a previous installation of MapGuide, be aware that these will have to be fixed one way or another.
=Copy to a Live Server= 
optional
You can run a script that shuts down IIS on my VMWare Server, stops the MapGuide service (use "net stop|start" instead of sc on platforms earlier than XP), and then starts them back up. This has some lazy bits in it (such as the PHP extension install).
 iisreset \\MyComputerName /stop
 
 sc \\MyComputerName stop MapGuideServer
 
 REM Server Copy
 xcopy "D:\OSGeo\MGBuild\Server\RepositoryAdmin" "\\MyComputerName\c$\Program Files\MapGuideOpenSource\Server\RepositoryAdmin" /E /Y /Q
 xcopy "D:\OSGeo\MGBuild\Server\bin\release" "\\MyComputerName\c$\Program Files\MapGuideOpenSource\Server\bin" /E /Y /Q
 xcopy "D:\OSGeo\MGBuild\Oem\gdal-1.3.0\data" "\\MyComputerName\c$\Program Files\MapGuideOpenSource\Server\data" /E /Y /Q
 xcopy "D:\OSGeo\MGBuild\Oem\proj-4.4.9\nad" "\\MyComputerName\c$\Program Files\MapGuideOpenSource\Server\nad" /E /Y /Q
 
 REM Web Extensions Copy
 xcopy "D:\OSGeo\MGBuild\Oem\gdal-1.3.0\data" "\\MyComputerName\c$\Program Files\MapGuideOpenSource\WebServerExtensions\www\data" /E /Y /Q
 xcopy "D:\OSGeo\MGBuild\Web\src\localized" "\\MyComputerName\c$\Program Files\MapGuideOpenSource\WebServerExtensions\www\localized" /E /Y /Q
 xcopy "D:\OSGeo\MGBuild\Web\src\mapadmin" "\\MyComputerName\c$\Program Files\MapGuideOpenSource\WebServerExtensions\www\mapadmin" /E /Y /Q
 xcopy "D:\OSGeo\MGBuild\Web\src\mapagent" "\\MyComputerName\c$\Program Files\MapGuideOpenSource\WebServerExtensions\www\mapagent" /E /Y /Q
 xcopy "D:\OSGeo\MGBuild\Web\bin\release" "\\MyComputerName\c$\Program Files\MapGuideOpenSource\WebServerExtensions\www\mapagent" /E /Y /EXCLUDE:mg_exclusions_mapagent.txt /Q
 xcopy "D:\OSGeo\MGBuild\UnitTest\WebTier\MapAgent\MapAgentForms" "\\MyComputerName\c$\Program Files\MapGuideOpenSource\WebServerExtensions\www\mapagent" /E /Y /Q
 xcopy "D:\OSGeo\MGBuild\Web\src\mapviewerphp" "\\MyComputerName\c$\Program Files\MapGuideOpenSource\WebServerExtensions\www\mapviewerphp" /E /Y /Q
 xcopy "D:\OSGeo\MGBuild\Oem\proj-4.4.9\nad" "\\MyComputerName\c$\Program Files\MapGuideOpenSource\WebServerExtensions\www\nad" /E /Y /Q
 xcopy "D:\OSGeo\MGBuild\Web\src\stdicons" "\\MyComputerName\c$\Program Files\MapGuideOpenSource\WebServerExtensions\www\stdicons" /E /Y /Q
 xcopy "D:\OSGeo\MGBuild\Web\src\viewerfiles" "\\MyComputerName\c$\Program Files\MapGuideOpenSource\WebServerExtensions\www\viewerfiles" /E /Y /Q
 xcopy "D:\OSGeo\MGBuild\Web\src\webstudio" "\\MyComputerName\c$\Program Files\MapGuideOpenSource\WebServerExtensions\www\webstudio" /E /Y /Q
 xcopy "D:\OSGeo\MGBuild\Oem\fcgi\isapi\isapi_fcgi\Release\isapi_fcgi.dll" "\\MyComputerName\c$\Program Files\MapGuideOpenSource\WebServerExtensions\www\mapagent" /E /Y /Q
 xcopy "D:\OSGeo\MGBuild\Oem\fcgi\fcgi-2.4.0\libfcgi\Release\libfcgi.dll" "\\MyComputerName\c$\Program Files\MapGuideOpenSource\WebServerExtensions\www\mapagent" /E /Y /Q
 
 REM PHP Extension Copy
 xcopy "D:\OSGeo\MGBuild\Web\bin\release" "\\MyComputerName\c$\Program Files\MapGuideOpenSource\WebServerExtensions\Php\ext\" /E /Y /EXCLUDE:mg_exclusions_php.txt /Q
 xcopy "D:\OSGeo\MGBuild\Web\bin\release" "\\MyComputerName\c$\Program Files\MapGuideOpenSource\WebServerExtensions\Php\" /E /Y /EXCLUDE:mg_exclusions_php.txt /Q
 
 sc \\MyComputerName start MapGuideServer
 
 iisreset \\MyComputerName /start
And here are the XCOPY exclusion files:
mg_exclusions_php.txt
 DotNet
 Java
mg_exclusions_mapagent.txt
 php_MapGuideApi
=Package=
optional
And of course you could do something really similar that packages the build for installation elsewhere.
 REM Server Copy
 xcopy "D:\OSGeo\MGBuild\Server\RepositoryAdmin" "D:\OSGeo\MGPkg\Server\RepositoryAdmin" /I /E /Y /Q
 xcopy "D:\OSGeo\MGBuild\Server\bin\release" "D:\OSGeo\MGPkg\Server\bin" /I /E /Y /Q
 xcopy "D:\OSGeo\MGBuild\Oem\gdal-1.3.0\data" "D:\OSGeo\MGPkg\Server\data" /I /E /Y /Q
 xcopy "D:\OSGeo\MGBuild\Oem\proj-4.4.9\nad" "D:\OSGeo\MGPkg\Server\nad" /I /E /Y /Q
 
 REM Web Extensions Copy
 xcopy "D:\OSGeo\MGBuild\Oem\gdal-1.3.0\data" "D:\OSGeo\MGPkg\WebServerExtensions\www\data" /I /E /Y /Q
 xcopy "D:\OSGeo\MGBuild\Web\src\localized" "D:\OSGeo\MGPkg\WebServerExtensions\www\localized" /I /E /Y /Q
 xcopy "D:\OSGeo\MGBuild\Web\src\mapadmin" "D:\OSGeo\MGPkg\WebServerExtensions\www\mapadmin" /I /E /Y /Q
 xcopy "D:\OSGeo\MGBuild\Web\src\mapagent" "D:\OSGeo\MGPkg\WebServerExtensions\www\mapagent" /I /E /Y /Q
 xcopy "D:\OSGeo\MGBuild\Web\bin\release" "D:\OSGeo\MGPkg\WebServerExtensions\www\mapagent" /I /E /Y /EXCLUDE:mg_exclusions_mapagent.txt /Q
 xcopy "D:\OSGeo\MGBuild\UnitTest\WebTier\MapAgent\MapAgentForms" "D:\OSGeo\MGPkg\WebServerExtensions\www\mapagent" /I /E /Y /Q
 xcopy "D:\OSGeo\MGBuild\Web\src\mapviewerphp" "D:\OSGeo\MGPkg\WebServerExtensions\www\mapviewerphp" /I /E /Y /Q
 xcopy "D:\OSGeo\MGBuild\Oem\proj-4.4.9\nad" "D:\OSGeo\MGPkg\WebServerExtensions\www\nad" /I /E /Y /Q
 xcopy "D:\OSGeo\MGBuild\Web\src\stdicons" "D:\OSGeo\MGPkg\WebServerExtensions\www\stdicons" /I /E /Y /Q
 xcopy "D:\OSGeo\MGBuild\Web\src\viewerfiles" "D:\OSGeo\MGPkg\WebServerExtensions\www\viewerfiles" /I /E /Y /Q
 xcopy "D:\OSGeo\MGBuild\Web\src\webstudio" "D:\OSGeo\MGPkg\WebServerExtensions\www\webstudio" /I /E /Y /Q
 
 REM PHP Extension Copy
 xcopy "D:\OSGeo\MGBuild\Web\bin\release" "D:\OSGeo\MGPkg\WebServerExtensions\Php\ext\" /I /E /Y /EXCLUDE:mg_exclusions_php.txt /Q
 xcopy "D:\OSGeo\MGBuild\Web\bin\release" "D:\OSGeo\MGPkg\WebServerExtensions\Php\" /I /E /Y /EXCLUDE:mg_exclusions_php.txt /Q
=Download the Batchfiles= 
optional
If you want, you can download the (slightly different than these instructions) batchfiles that Jason uses from his site:
 
http://www.jasonbirch.com/files/mapguide_build.zip