-
Notifications
You must be signed in to change notification settings - Fork 3.8k
Windows Compilation
Compiling OSRM on Windows is not straight forward right now. This steps lead us to a correct OSRM compilation and running over Windows 7, but cannot warrantee you anything.
Use always a 64bit version, because 32bit versions will lack of RAM too easily and throw weird errors.
- x64 Windows machine
- Microsoft Visual Studio 2008 Professional Edition with x64 compiler installed or Microsoft Visual Studio 2008 Express Edition (only from x32 builds)
| vsprojects[\x64]\Release mean vsprojects\Release or vsprojects\x64\Release depending on choosen platform |
- Download and extract the content
DennisOSRM-Project-OSRM-v0.3b-0-gcaf9086.tar.gzto a folder in computer (Ex:C:\Osrm) - Create a folder named
libin OSRM folder (Ex:C:\Osrm\lib)
Download and extract the content of boost_1_49_0.zip to boost dir from lib (Ex: C:\Osrm\lib\boost)
- For x32 run in boost dir from a cmd prompt:
C:\Osrm\lib\boost>bootstratp
C:\Osrm\lib\boost>b2 —build-type=complete
- For x64 run in boost dir from a cmd prompt:
C:\Osrm\lib\boost>boostrap
C:\Osrm\lib\boost>bjam —toolset=msvc-9.0 address-model=64 —build-type=complete stage
This compilation will take a long time to finish and will add another 5-7 GB of data to boost folder.
- Download and extract the content of bzip2-1.0.6.tar.gz to bzip2 dir from lib (Ex:
C:\Osrm\lib\bzip2)- For x32 just open
libbz2.dspand convert tolibbz2.slnand build using release version. - For x64 open
libbz2.dspand convert tolibbz2.slnand choose a new configuration based on release version of x32 but at target processor choose x64
(“Build” menu → “Configuration Manager”: “Active solutions configuration” → “Release” and “Active solution platform” → “New” → “Type or select the new platform” → “x64” also “Copy settings from” → “Win32”, check “Create new project platforms”).
- For x32 just open
- After rebuilding create three folders in bzip2 dir named
bin,libandinclude - Copy
libbz2.dllfrombzip2folder inbzip2\bin - Copy
libbz.libfrombzip2\Releasefolder inbzip2\lib - Copy
bzlib.hfrombzip2folder inbzip2\include
- Download and extract the content of protobuf-2.4.1.zip to protobuf folder from lib (Ex:
C:\Osrm\lib\protobuf)- For x32 just open
protobuf.slnfromvsprojectsand build using release version.
Build and after fail (will fail for sure) download protoc-2.4.1-win32.zip and copyprotoc.exeinvsprojects\Release, rebuild the project (now you will have some fails but the library is compiled). - For x64 open
protobuf.sln fromvsprojectsand choose a new configuration based on release version of x32 but at target processor choose x64
(“Build” menu → “Configuration Manager”: “Active solutions configuration” → “Release” and “Active solution platform” → “New” → “Type or select the new platform” → “x64” also “Copy settings from” → “Win32”, check “Create new project platforms”).
Rebuild and after fail (will fail for sure) download protoc-2.4.1-win32.zip and copyprotoc.exeinvsprojects[\x64]\Releaseand rebuild the project (now you will have some fails but the library is compiled).
- For x32 just open
- After second rebuild run
extract_includes.batfromvsprojectsfolder (this will create the include folder invsprojects). - Make three folders in protobuf named
bin,libandinclude. - Copy
protoc.exefromprotobuf\vsprojects[\x64]\Releasetoprotobuf\bin. - Copy the content of
includefolder fromprotobuf\vsprojects\includetoprotobuf\include. - Copy
*.libfromprotobuf\vsprojects[\x64]\Releaseinprotobuf\lib.
- Download and extract the content of sparsehash-2.0.2.zip to sparsehash folder from lib (Ex:
C:\Osrm\lib\sparsehash).- For x32 just open
sparsehash.slnand rebuild using release version. - For x64 open
sparsehash.slnand choose a new configuration based on release version of x32 but at target processor choose x64
(“Build” menu → “Configuration Manager”: “Active solutions configuration” → “Release” and “Active solution platform” → “New” → “Type or select the new platform” → “x64” also “Copy settings from” → “Win32”, check “Create new project platforms”)
- For x32 just open
- Rebuild solution.
- Download and extract the content of stxxl-1.3.1.zip to stxxl folder from lib (Ex:
C:\Osrm\lib\stxxl) - Create a file named
make.settings.localin stxxl folder with folowing content:
BOOST_ROOT = “$(TOPDIR)\..\boost”# - Add
/LIBPATH:$(BOOST_ROOT)\stage\lib\inmake.settings.msvcbetween/LIBPATH:$(BOOST_ROOT)\lib\and/STACK:16777216 /NOLOGO(line 68) so this line become/LIBPATH:$(BOOST_ROOT)\lib\ /LIBPATH:$(BOOST_ROOT)\stage\lib\ /STACK:16777216 /NOLOGO
- If you compile for debug you need to add
DEBUG_COMPILER=/MDd /Zi
andDEBUG_LINKER=/DEBUGtomake.settings.local - Compile
- For x32 just open
stxxl.slnand rebuild using “Library” - For x64 open
stxxl.slnand choose a new configuration based on x32 Library but at target processor choose x64
(“Build” menu → “Configuration Manager”: “Active solutions configuration” → “Library” and “Active solution platform” → “New” → “Type or select the new platform” → “x64” also “Copy settings from” → “Win32”, check “Create new project platforms”)
- For x32 just open
- Rebuild solution.
Download and extract the content of zlib-1.2.7.tar.gz to zlib folder from lib (Ex: C:\Osrm\lib\zlib).
- Download and install masm32
- Open a cmd promt and go to
zlib\contrib\masmx86folder. - Add
C:\masm32\binto path:C:\Osrm\lib\zlib\contrib\masmx86\>SET path=C:\masm32\bin;%path%
- Run
bld_ml32.batfromzlib\contrib\masmx86folder. - Go to root zlib folder and run:
C:\Osrm\lib\zlib\>"C:\Program Files\Microsoft Visual Studio 9.0\VC\vcpackages\vcbuild.exe" /rebuild contrib\vstudio\vc9\zlibvc.sln “Release|Win32”
- Create thre folders in zlib named
bin,libandinclude. - Copy
zlib\contrib\vstudio\vc9\x86\ZlibDllRelease\zlibwapi.dlltozlib\bin\zlib.dll. - Copy
zlib\zconf.htozlib\include\zconf.h - Copy
zlib\zlib.htozlib\inc\zlib.h - Copy
zlib\contrib\vstudio\vc9\x86\ZlibDllRelease\zlibwapi.libtozlib\lib\zlib.lib
- Open a cmd promt and go to
zlib\contrib\masmx64folder. - Add
C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\bin\x86_amd64to pathC:\Osrm\lib\zlib\contrib\masmx64\>SET path=C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\bin\x86_amd64;%path%
- Run
bld_ml64.batfromzlib\contrib\masmx64folder. - Open
zlibvc.slnfromzlib\contrib\vstudio\vc9folder and choose a Release version with 64 bits from build → configuration manager. - Rebuid the solution.
- Create thre folders in zlib named
bin,libandinclude. - Copy
zlib\contrib\vstudio\vc9\x64\ZlibDllRelease\zlibwapi.dlltozlib\bin\zlibwapi.dll. - Copy
zlib\zconf.htozlib\include\zconf.h. - copy
zlib\zlib.htozlib\inc\zlib.h. - Copy
zlib\contrib\vstudio\vc9\x64\ZlibDllRelease\zlibwapi.libtozlib\lib\zlib.lib.
Create libxml2 folder (Ex: C:\Osrm\lib\libxml2)
Look for a precompiled version of libxml2 (libxml2_x64.zip from project files) for x64 (usually from a x64 apache install), download the dll and extract the exported symbols to a def file (look at http://www.coderetard.com/2009/01/21/generate-a-lib-from-a-dll-with-visual-studio/ for more info).
For lib program use /machine:x64 option.
For x32 you will find precompiled library (file libxml2-2.7.8.win32.zip).
- Download the libxml2-2.7.8.win32.zip file.
- Make a folder named
libxml2and make in this three new subfolders namedbin,libandinclude. - Copy in
libxml2\binthe downloaded dll (libxml2.dll) - Copy in
libxml2\libthe created import library (libxml2.lib) - Copy in
libxml2\includethelibxmlfolder fromlibxml2-2.7.8.win32.zip\include
Download and extract the libiconv-1.14.tar.gz to libiconv folder from lib (Ex: C:\Osrm\lib\libiconv).
Use http://www.codeproject.com/Articles/302012/How-to-Build-libiconv-with-Microsoft-Visual-Studio as a guide for building a project for iconv (libiconv_vcproject.zip from project files).
- Open
libiconv.slnfromlibiconv\libiconvfolder and choose a new configuration based on release version of x32 but at target processor choose x64
(“Build” menu → “Configuration Manager”: “Active solutions configuration” → “Release” and “Active solution platform” → “New” → “Type or select the new platform” → “x64” also “Copy settings from” → “Win32”, check “Create new project platforms”). - After rebuild create a folder named
iconvinlib(Ex:C:\Osrm\lib\iconv). - Create three new folders in iconv named
bin,libandinclude. - Copy
libiconv.dllfromlibiconv\libiconv\x64\Releasetoiconv\bin. - Copy
libiconv.libfrom libiconv\libiconv\x64\Release toiconv\lib. - Copy content of
libiconv\libiconv\includeiniconv\include.
You can find precompiled version of the lib (libiconv-1.9.2-1-bin.zip and libiconv-1.9.2-1-lib.zip).
Edit osrm.vsprops from c:\Osrm\vcprojects adjusting paths to indicate the folders from lib dir
- Open
osrm.slnfromOsrm\vcprojectsand choose a new configuration based on release version of x32 but at target processor choose x64
(“Build” menu → “Configuration Manager”: “Active solutions configuration” → “Release” and “Active solution platform” → “New” → “Type or select the new platform” → “x64” also “Copy settings from” → “Win32”, check “Create new project platforms”)
Rebuild solution.
- Modify
Osrm\DataStructures\NNGrid.hand add
#undef min
before line 51
#undef maxstatic const unsigned MAX_CACHE_ELEMENTS = 1000; - Modify
Osrm\typedefs.hand comment line 51:
#define DELETE do { if(NULL != x) { delete x; x = NULL; } }while(0);
- Modify
Osrm\routed.cppline 134 and replaceDELETE(s);with
do { if(NULL != s) { delete s; s = NULL; } }while(0);andDELETE(objects);from line 135 with
do { if(NULL != objects) { delete objects; objects = NULL; } }while(0); - Modify
Osrm\createHierarchy.cppand ReplaceDELETE(edgeBasedGraphFactory);on line 143 with
do { if(NULL != edgeBasedGraphFactory) { delete edgeBasedGraphFactory; edgeBasedGraphFactory = NULL; } }while(0);andDELETE( writeableGrid );from line 148 withdo { if(NULL != writeableGrid) { delete writeableGrid; writeableGrid = NULL; } }while(0);andDELETE( cleanup );from line 178 withdo { if(NULL != cleanup) { delete cleanup; cleanup = NULL; } }while(0); - Comment or delete
typenamefromOsrm\Contractor\EdgeBasedGraphFactory.cppline 42for ( /typename/ std::vector< NodeBasedEdge >::const_iterator i = …
- In
Osrm\Contractor\EdgeBasedGraphFactory.cppchange line 105 fromwhile(restrictionIterator→fromNode < u && inputRestrictions.end() != restrictionIterator) {towhile(inputRestrictions.end() != restrictionIterator && restrictionIterator→fromNode < u) {line 117 fromif(u == restrictionIterator→fromNode) {toif(inputRestrictions.end() != restrictionIterator && u == restrictionIterator→fromNode) {line 120 fromif(v == secondRestrictionIterator→viaNode && w == secondRestrictionIterator→toNode) {toif(inputRestrictions.end() != secondRestrictionIterator && v == secondRestrictionIterator→viaNode && w == secondRestrictionIterator→toNode) {and line 124 from} while(u == secondRestrictionIterator→fromNode);
to} while(inputRestrictions.end() != secondRestrictionIterator && u == secondRestrictionIterator→fromNode);
- Remove inline definition of
gettimeofdayfromOsrm\DataStructures\Util.hline 36 adding this function in a new file namedUtil.cpp inthe same foldervoid gettimeofday(struct timeval* t,void* timezone);
in header and#include “Util.h”
void gettimeofday(struct timeval* t,void* timezone)
{
struct _timeb timebuffer;
ftime( &timebuffer );
t→tv_sec=timebuffer.time;
t→tvusec=1000*timebuffer.millitm;
}
in cpp. - Add
Osrm\DataStructures\Util.cppandOsrm\Contractor\EdgeBasedGraphFactory.cppto project (add existing file) - Add
$(BoostPath)\stage\libin project properties → linker → General → Additional library directories. - Rebuild project.
- Add
DataStructures\Util.cppto project. - Add
$(BoostPath)\stage\libin Project properties → Linker → General → Additional library directories - Rebuild project.
- Replace
DELETE;fromOsrm\Server\RequestHandler.hline 47 withdo { if(NULL != tempPointer) { delete tempPointer; tempPointer = NULL; } }while(0); - Replace
DELETE;fromOsrm\Plugins\ViaRoutePlugin.hline 68 withdo { if(NULL != searchEngine) { delete searchEngine; searchEngine = NULL; } }while(0);andDELETE;from line 268 withdo { if(NULL != desc) { delete desc; desc = NULL; } }while(0); - Add
Osrm\Descriptors\DescriptionFactory.cppto project. - Add
$(BoostPath)\stage\libin Project properties → Linker → General → Additional library directories. - Rebuild project.
- Copy
libxml2.dllfromOsrm\lib\libxml2\binto exe folder (Osrm\vcprojects\x64\Release). - Copy
zlibwapi.dllfromOsrm\lib\zlib\binto exe folder (Osrm\vcprojects\x64\Release). - Change
server.inifromOsrm\vcprojects\x64\Releasefolder to indicate at correct files. - Modify
Osrm\Docs\WebFrontend\Route.jsline 32 to use local server for test.
On server you will need to install Microsoft Visual C++ 2008 Redistributable SP1 (vcredist_x64.exe from project files)
Kudos to pixecs, who did a great job.
Kudos to Emergya for supporting this build.