Сборка OSRM - построение маршрутов

Собрать под Win64 несложно из исходников https://github.com/LuaDist/luasql-postgresql


git clone http://github.com/LuaDist/luasql-postgresql.git
cd luasql-postgresql
cmake -G "Visual Studio 11 Win64" -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=r:/libs 

(в r:/libs должны лежать Lua и библиотеки PostgreSql)
Нужно знать конкретную версию Lua и Postgresql (с другими потом не заработает). Если нужно, скажите версии - соберу (это 5 минут).

Ок, попробую сам. http://www.cmake.org/files/v2.8/cmake-2.8.12.2-win32-x86.exe - это подойдёт?

Исходники, насколько я понимаю. верно?

Cmake -верно. Еще нужна студия или Windows sdk. Lua перед этим тоже придется собрать из соседнего репозитория и проинсталлировать в r:/libs В дистрибутиве postrgresql должны быть include-файлы и .lib-файлы (их положить в соотв. папки)

VS Express 2013 for Desktop имеется, достаточно будет?

Должно быть достаточно (у нас полная версия по DreamSpark, так что не пробовал). Если вдруг не хватит стандартных библиотек, можно доустановить Windows 8 SDK.

Вместо запуска cmake из консоли можно пользоваться cmake-gui .
Вот моя инструкция по сборке osrm с батниками (там есть Lua): https://gist.github.com/alex85k/8637217

Хватит, я alacarte собираю со всеми зависимостями из исходников в Экспресс версии. Правда в 2013 какие-то проблемы с ХР.

Вот спасибо хорошо, для VS2013 Express некоторые моменты пришлось переиначить :slight_smile:

И для win8.1 в build_other.bat пришлось поменять кусок с xcopy для protobuf на

xcopy /S /E /Y src\google %PREFIX%\include\google\
xcopy /S /E /Y bin\*.exe %PREFIX%\bin

ключ /D для указания даты используется, а если после \include\google не ставить слэш, то во время выполнения будет спрашивать файл это или директория.

И ещё внести небольшие изменения в protobuf:
https://code.google.com/p/protobuf/issues/detail?id=531

При сборке возникает такая хрень - ругается на src/ls_postgres.c

/*
** Escapes a string for use within an SQL statement.
** Returns a string with the escaped string.
*/
static int conn_escape (lua_State *L) {
	conn_data *conn = getconnection (L);
	size_t len;
	const char *from = luaL_checklstring (L, 2, &len);
374:	char to[len*sizeof(char)* 2 + 1];
	int error;
376:	len = PQescapeStringConn (conn->pg_conn, to, from, len, &error);
	if (error == 0) { /* success ! */
378:		lua_pushlstring (L, to, len);
		return 1;
	} else
		return luasql_failmsg (L, "cannot escape string. PostgreSQL: ", PQerrorMessage (conn->pg_conn));
}

D:\jim>cd luasql-postgresql

D:\jim\luasql-postgresql>cmake -G "NMake Makefiles" -DCMAKE_BUILD_TYPE=Release -DSEARCH_PREFIX=%PREFIX% -DCMAKE_INSTALL_PREFIX=%PR
EFIX% -DPOSTGRESQL_INCLUDE_DIR=%PREFIX%/include/pgsql
DIST_NAME: luasql-postgresql
DIST_VERSION: 2.3.0
DIST_LICENSE: Kepler
DIST_AUTHOR: Roberto Ierusalimschy, Andr├й Carregal, Tom├бs Guisasola
DIST_MAINTAINER: Peter Kapec
DIST_URL: http://www.keplerproject.org/luasql/
DIST_DESC: Database connectivity for Lua - PostgreSQL driver
DIST_DEPENDS:
-- Found PostgreSQL: d:/jim/libs/include/pgsql
-- Found Lua: d:/jim/libs/lib/lua.lib
-- Configuring done
-- Generating done
CMake Warning:
  Manually-specified variables were not used by the project:

    SEARCH_PREFIX


-- Build files have been written to: D:/jim/luasql-postgresql

D:\jim\luasql-postgresql>nmake install

Microsoft (R) Program Maintenance Utility Version 12.00.21005.1
Copyright (C) Microsoft Corporation.  All rights reserved.

Scanning dependencies of target luasql_postgres
[ 50%] Building C object CMakeFiles/luasql_postgres.dir/src/ls_postgres.c.obj
ls_postgres.c
D:\jim\luasql-postgresql\src\ls_postgres.c(374) : error C2057: expected constant expression
D:\jim\luasql-postgresql\src\ls_postgres.c(374) : error C2466: cannot allocate an array of constant size 0
D:\jim\luasql-postgresql\src\ls_postgres.c(374) : error C2133: 'to' : unknown size
D:\jim\luasql-postgresql\src\ls_postgres.c(376) : warning C4090: 'function' : different 'const' qualifiers
NMAKE : fatal error U1077: 'C:\PROGRA~2\MICROS~3.0\VC\bin\X86_AM~1\cl.exe' : return code '0x2'
Stop.
NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\BIN\nmake.exe"' : return code '0x2'
Stop.
NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\BIN\nmake.exe"' : return code '0x2'
Stop.

В плюсах я не силён, подскажите куда копать?

Можно попробовать заменить

char to[len*sizeof(char)* 2 + 1];

на

char *to = (char*) malloc(sizeof(char)*(len*sizeof(char)* 2 + 1));

а в конце функции добавить

free(to);

Вот описание проблемы (несовместимость компилятора).
http://stackoverflow.com/questions/7303740/error-c2057-expected-constant-expression

Спасибо, завёл. Попробую прикрутить теперь это дело ко всему остальному. Осталось понять как это правильно сделать в Windows :slight_smile:

Насколько понимаю теперь надо собрать OSRM-Extract и прочее, чтобы они использовали полученный на выходе postgres.dll?

stxxl из репозитория Денниса так и не смог собрать, воспользовался http://github.com/stxxl/stxxl.git

Thanks for compiling OSRM in windows. I tried to do it myself, but failed :frowning:
Would you be so kind to share your complete project; incl boost, lua, protobuf etcetera?

I ask you this as I like to use the matrix functionality as discussed in https://github.com/DennisOSRM/Project-OSRM/issues/544

The project is path and VS-dependent, so sharing is not simple. But the following instructions and batch files may help:
https://gist.github.com/alex85k/8637217 (see readme.txt, basic libs sources are here: https://dl.dropboxusercontent.com/u/63393258/Build_OSRM.zip )
Discussion of changes are in https://github.com/DennisOSRM/Project-OSRM/pull/880. You can post the question there, so the developers could see the solutions and you inerest too :slight_smile:

По русски, на всякий случай: вот инструкция и батники по сборке на Windows: https://gist.github.com/alex85k/8637217

Hi akks,

I’ve seen these topics and tried them last week. Thanks to your reply I tried that again.

The first 4 steps of the readme are compiled without errors. The final step (compiling OSRM) fails with an error: Could not find the following static Boost libraries: boost_zlib. Do you use the same parameters as Alex wrote?

In Alex’ topic there are two different commands for compiling boost: with and without sZLIB_SOURCE. I tried them both. Using VS2013 64 bits.

Oh, I am sorry. Boost-ZLIB is actually needed by boost-iostreams (I’ll recheck bat file and recompile from scratch on VS2013, maybe updating to latest development version of OSRM). It is better to compile Boost with sources of BZIP and ZLIB


bjam toolset=msvc variant=release address-model=64 threading=multi link=static runtime-link=shared --prefix=%PREFIX% -sBZIP2_SOURCE=r:\Builld\bzip2-1.0.6 -sZLIB_SOURCE=r:\build\zlib-1.2.8 install

You can also try my pre-built library: https://dl.dropboxusercontent.com/u/63393258/libboost_zlib-vc110-mt-1_55.lib

P.S. alex85k is me too :slight_smile: Please let me know if other problems arise.

Fixed instructions and batch files for VS 2013 (now with needed ZLIB), added better library repositories:
Beware boost 1.55 incompatibility with VS2013 - the fix is described in readme.txt

Подправил инструкцию по сборке, теперь она работает (пересобрал всё заново для проверки)
Boost 1.55 приходится пропатчить для совместимости с VS2013, файлик для замены прилагается.
https://gist.github.com/alex85k/8637217#file-readme-txt

Now really updated build intsruction, use new 0.3.8 version.
https://gist.github.com/alex85k/8637217#file-readme-txt

Обновил сборку и патчи до последней версии OSRM.
https://github.com/alex85k/Project-OSRM/tree/win-038

Бинарная сборка:
OSRM-Windows-038.zip

Сборка, которая, возможно, заработает на системах старее Windows 7 (x64)
OSRM-WindowsXP-038.zip

Hi Alex,

Thanks for the update.
I followed the new instructions. It works almost.

When I use in the build_boost.bat “bjam toolset=msvc address-model=64 runtime-link=shared --prefix=%PREFIX% -sBZIP2_SOURCE=”%src%\bzip2-1.0.6" -sZLIB_SOURCE=“%src%\zlib-1.2.8” install" I get this error at the final build (OSRM): libboost_program_options-vc120-mt-1_55.lib(value_semantic.obj) : fatal error LNK1112: module machine type ‘x64’ conflicts with target machine type ‘X86’

I also see this message: “Building on a 32 bit system is unsupported”. Looking in CMakeLists.txt I see there is a test. I see what I did wrong: I opened the prompt via “Developer Command Prompt for VS2013”. Maybe you can mention to open the prompt by selecting “VS2013 x64 Cross Tools Command Prompt”? Anyway I started completely clean (deleted everything).

I’ve a small remark regarding build_base.bat: when you install libxml2 there is no version number in the path
I used these commands in the batfile:
git clone git://git.gnome.org/libxml2
rem cd libxml2-2.9.0/win32
cd libxml2/win32

In build_stxxl.bat please use %BOOST_ROOT% in the argument

Regarding stxxl, there is indeed no patch needed with vs2013 64bits.

When compiling the OSRM project I get at the end some weird externals errors. It looks like he still tries to compile in 32 bit mode. Here is the logfile: http://pastebin.com/aHQEjGRS

Regards

It seems you are using old 32 bit build of libxml2 (before starting x64 command prompt). I have tested bat-file on unpacked sources from ftp ftp://xmlsoft.org/libxml2/libxml2-sources-2.9.0.tar.gz
Problems should stop after recompiling it in correct console (I hope your Windows is 64 bit? Use “x64 Native Tools” command prompt) (remove old 32 bit libxml files from /libs)

Hi Alexander,

I started new. Using “VS2013 x64 Native Tools Command Prompt”, sorry I missed your “Variant 0”.

Now I get this error when compiling OSRM:
XMLParser.cpp.obj : error LNK2019: unresolved external symbol BZ2_bzReadOpen referenced in function “struct _xmlTextReader * __cdecl inputReaderFactory(char const *)” (?inputReaderFactory@@YAPEAU_xmlTextReader@@PEBD@Z)
In total 4 errors for the extractor, see the last lines in pastebin.

Also a lot of warnings, could that be a problem?

BZIP2 library is not found correctly. Be sure that library (.lib) and header path for bzip2 exist and are listed in CakeCache.txt