User:Shrddr/libosmscout

From OpenStreetMap Wiki
Jump to navigation Jump to search

Building and running libosmscout under Windows

Tested using

  • Visual Studio Community 2013 Update 4
  • Qt 5.5.0 for Windows 32-bit (VS 2013)
  • Windows 7 SP1

Debug Configuration

libosmscout

This is a base library for everything else.

  • Download a source code snapshot from http://sourceforge.net/projects/libosmscout/
  • Move .vcxproj files and include folders from libosmscout-code\windows\xxx to upper level project directories libosmscout-code\xxx (xxx = Import, libosmscout, libosmscout-import, etc.). Rename the project files, cutting off msvc2013_ prefixes.
  • Edit msvc2015_libosmscout.sln to correct the path to libosmscout.vcxproj and open the solution.
  • Open Project properties and select All Configurations in the Configuration drop box. This will make our changes apply to both Debug and Release configurations. In the tree below, go to Configuration Properties > C/C++ > Preprocessor > Preprocessor Definitions, and add
OSMSCOUT_EXPORT_SYMBOLS;
  • Delete Reference.cpp from project
  • At the top of Progress.h file, add:
#include <stdint.h>
  • Build project

libosmscout-import

This is a library required by the Import application.

  • Add preprocessor definition
OSMSCOUT_IMPORT_EXPORT_SYMBOLS;
  • Download libxml2, iconv and zlib windows binaries from http://www.zlatkovic.com/libxml.en.html. Copy include files to libosmscout-import\include, copy libxml2.lib to libosmscout-import\lib
  • Go to Project properties > Configuration Properties > Linker > Input > Additional Dependencies and add
$(ProjectDir)\lib\libxml2.lib;
  • Place the libxml2.dll, iconv.dll and zlib1.dll to output folder or any PATH folder like C:\Windows
  • Build project

Import

This is a tool to convert .osm XML files to indexed binary format. Note that some data is going to be dropped in conversion process. Libosmscout is mobile device oriented, so it keeps data size to miniumum. You can play around with the .ost file to import different objects if you want to. This project should build without problems. To use it, find an .osm data file to import from. After that, run

import --typefile ..\..\stylesheets\map.ost --destinationDirectory yourdatafolder yourmapfile.osm
  • Don't download .osm data directly using http://www.openstreetmap.org Export button - resulting files don't have node id's sorted and the library will report import error. There should be links below to get sorted data from overpass or geofabrik.
  • Don't set destination to a nonexistent directory. Create it manually first.
  • In a debug build, there will be quite a bit of "debug assertion failed" messages. Press ignore, multiple times - or build release version.

libosmscout-map

This is a base renderer interface, used by specific renderer implementations like libosmscout-map-qt.

  • Add preprocessor definition
OSMSCOUT_MAP_EXPORT_SYMBOLS;
  • Build project.

libosmscout-map-qt

This library is a qt-based renderer used by OSMScout2. There are other renderers available for different applications.

  • Go to http://www.qt.io/download-open-source/ and download Qt for Windows 32-bit (VS 2013). Qt Creator comes with that download, so I'll be using it instead of Visual Studio.
  • Copy include\MapQtFeatures.h.in to MapQtFeatures.h
  • Add following lines at the top of MapPainterQt.h
#if defined(WIN32)
    #include <BaseTsd.h>
    typedef SSIZE_T ssize_t;
#endif
  • Open project with Qt Creator and build.

If you edit project file while it's open in Creator, right click the project and Run QMake to apply changes.

OSMScout2

This demo application displays data which was prepared earlier using Import tool. The appearance of the map is controlled by the .oss file.

  • No configuration here, just Build project
  • If you run OSMScout standalone executable, it starts a process but doesn't show any window. To fix that, add C:\Qt\Qt5.5.0\5.5\msvc2013\bin to your PATH environment variable.
  • Arguments are not passed to application so you have to put imported data files and stylesheets\standard.oss into your executable folder. To fix that, comment out WinMain callback at the very bottom of OSMScout.cpp.
//int CALLBACK WinMain(HINSTANCE /*hInstance*/, HINSTANCE /*hPrevInstance*/, LPSTR /*lpCmdLine*/, int /*nCmdShow*/){
//	main(0, NULL);
//}

After that, run with parameters:

osmscout yourdatafolder ../../stylesheets/standard.oss ../../libosmscout/data/icons/14x14/standard/

Release Configuration

Following steps assume you have already built the Debug versions.

marisa

This library is required for Release version of libosmscout.

#include <functional>
  • marisa-common-prefix-search.cc, marisa-predictive-search.cc: add
#include <algorithm>
  • Build solution

libosmscout

  • Go to Project Properties > Configuration Properties > C/C++ > General > Additional Include Directories, switch Configuration to Release and add
$(ProjectDir)\include;
  • Copy marisa headers to include folder
  • Copy compiled libmarisa.lib to lib\libmarisa.lib and link
$(ProjectDir)\lib\libmarisa.lib;
  • Exclude tests from build
  • Build project

libosmscout-import

  • Add Include Directories for Release Configuration
$(ProjectDir)\include;$(ProjectDir)\..\libosmscout\include;
  • Build project

Import

  • Add Include Directories for Release Configuration
$(ProjectDir)\..\libosmscout\include;$(ProjectDir)\..\libosmscout-import\include
  • Build project

libosmscout-map

  • Add Include Directories for Release Configuration
$(ProjectDir)\include;$(ProjectDir)..\libosmscout\include
  • Build project

libosmscout-map-qt

  • Build project

OSMScout2

  • Remove debug from CONFIG += line in project file
  • Right click project > Run QMake
  • Build project