Skip to content
Matt Styles edited this page Jul 20, 2016 · 5 revisions

The map loader has been tested to work on both Linux and Windows and, I believe, some people have had success using it on OS X. Building the map loader does, however, vary slightly between platforms.

NOTE the 'next' branch of the repository has an improved build / cmake system which allows building the map loader correctly as both a shared and static library. It also removes the zlib dependency (while still supporting compressed maps) making building on windows a lot easier. If you are starting from scratch then it may be worth using.

###Windows #####Visual Studio Firstly you will need to build the zlib library. zlib is required for compressed format TMX files. You can build and link zlib either statically or dynamically, the only mandate is that it is built for your version of Visual Studio. Instructions on building zlib can be found in this useful article. Although the article cites Visual Studio 2012 I've tested it to also work on 2013 and 2015, you simply let your copy of Visual Studio upgrade the project supplied in the zlib archive.

Once you've built zlib, link it to your project in the same way you would link any other library by adding it to Additional Dependencies under Project Properties->Linker->Input:

Link Settings

Although the map loader comes with a CMake file currently the source of the map loader does not include the export macros required by Visual Studio to see functions exported in dynamic libraries. This means that, although you could use the CMake file to build a static library, sometimes it's easier to just include the source files in your project. This means you should also include the pugixml files, although tmx2box2d.cpp should only be added if your project links to the Box2D library. Including this file without Box2D will otherwise lead to linker errors.

SourceTree

The above images shows the Isometric sample included with the map loader source.

A Working Template Visual Studio Project can be found here for those who want a quick start on an empty project.

#####MinGW Building with MinGW on windows is not dissimilar to building on linux. Again you must have zlib built and installed for your version of of your compiler, but then it is possible to use the CMake file in the map loader repository to create make files which build with MinGW. In this case the map loader can be built as either a static or dynamic library, and linked to your project normally.

###Linux #####g++ (and, in theory, clang) Building on linux is usually pretty straight forward as most distributions have all the required libraries available via their package manager. To begin install SFML, zlib and optionally Box2D, either from the package manager or from source if you prefer the latest versions. Once these are installed clone the map loader repository, navigate to its directory and do something similar to:

mkdir build && cd build
cmake .. && make
sudo make install

Which will build and install the map loader as a shared library, ready for linking to your project. Optionally use the cmake-gui (or the command line) to configure CMake, which will allow you to build the library statically and build the included examples.

###OS X TODO...

Clone this wiki locally