diff --git a/demo/c++/Makefile b/demo/c++/Makefile index d30b71b40..dbd425380 100644 --- a/demo/c++/Makefile +++ b/demo/c++/Makefile @@ -1,4 +1,4 @@ -CXXFLAGS = $(shell mapnik-config --cflags) +CXXFLAGS = $(shell mapnik-config --includes --defines --cxxflags --dep-includes) LDFLAGS = $(shell mapnik-config --libs --dep-libs --ldflags) OBJ = rundemo.o @@ -13,8 +13,15 @@ $(BIN) : $(OBJ) .c.o : $(CXX) -c $(CXXFLAGS) $< +gyp: + rm -rf ./build + gyp rundemo.gyp --depth=. -f make --generator-output=./build/ + make -C ./build + build/out/Release/rundemo `mapnik-config --prefix` + .PHONY : clean clean: rm -f $(OBJ) rm -f $(BIN) + rm -f ./build \ No newline at end of file diff --git a/demo/c++/README.md b/demo/c++/README.md new file mode 100644 index 000000000..77e071a15 --- /dev/null +++ b/demo/c++/README.md @@ -0,0 +1,70 @@ +## rundemo.cpp + +This directory contains a simple c++ program demonstrating the Mapnik C++ API. It mimics the python 'rundemo.py' example with a couple exceptions. + +If building on unix you can have this program automatically build by configuring Mapnik like: + + ./configure DEMO=True + +However, this example code also should be able to be built standalone. + +The following notes describe how to do that on various operating systems. + +## Depends + + - Mapnik library development headers + - `mapnik-config` on unix and `mapnik-config.bat` on windows + +### Unix + +On OS X and Linux you also need `make`. + +### Windows + +On windows, additional dependencies to build are: + + - MSVS 2010 with C++ compiler + - Python 2.x + - gyp: https://code.google.com/p/gyp | https://github.com/springmeyer/hello-gyp + +`mapnik-config.bat` should come with your Mapnik installation. + +First confirm it is on your path: + + mapnik-config # should give usage + +To install gyp, which is pure python do: + + svn checkout http://gyp.googlecode.com/svn/trunk/ gyp + cd gyp + sudo python setup.py install + + +## Building the demo + +### Unix + +Simply type: + + make + +Then to run do: + + ./rundemo `mapnik-config --prefix` + +On OS X you can also create an xcode project: + + gyp rundemo.gyp --depth=. -f xcode --generator-output=./build/ + xcodebuild -project ./build/rundemo.xcodeproj + ./build/out/Release/rundemo `mapnik-config --prefix` + + +### Windows + +First you need to build he visual studio files with gyp: + + gyp rundemo.gyp --depth=. -f msvs -G msvs_version=2010 + +Then you can compile the demo with `msbuild`: + + msbuild build.sln \ No newline at end of file diff --git a/demo/c++/common.gypi b/demo/c++/common.gypi new file mode 100644 index 000000000..2dd800c78 --- /dev/null +++ b/demo/c++/common.gypi @@ -0,0 +1,42 @@ +{ + 'variables': { + 'conditions': [ + ['OS == "mac"', { + 'target_arch%': 'x64' + }, { + 'target_arch%': 'ia32' + }] + ] + }, + 'target_defaults': { + 'default_configuration': 'Release', + 'defines': [ ], + 'conditions': [ + ['OS == "mac"', { + 'defines': [ 'DARWIN' ] + }, { + 'defines': [ 'LINUX' ] + }], + ['OS == "mac" and target_arch == "x64"', { + 'xcode_settings': { + 'ARCHS': [ 'x86_64' ] + }, + }] + ], + 'configurations': { + 'Debug': { + 'cflags': [ '-g', '-O0' ], + 'xcode_settings': { + 'OTHER_CFLAGS': [ '-g', '-O0' ] + } + }, + 'Release': { + 'cflags': [ '-O3' ], + 'defines': [ 'NDEBUG' ], + 'xcode_settings': { + 'OTHER_CFLAGS': [ '-O3' ] + } + } + } + } +} \ No newline at end of file diff --git a/demo/c++/readme.txt b/demo/c++/readme.txt deleted file mode 100644 index c9d546bc5..000000000 --- a/demo/c++/readme.txt +++ /dev/null @@ -1,20 +0,0 @@ -This directory contains a simple c++ program demonstrating the Mapnik C++ API. It mimics the python 'rundemo.py' example with a couple exceptions. - -To build it re-configure SCons with DEMO=True then rebuild:: - - $ python scons/scons.py configure DEMO=True - $ python scons/scons.py - - -The sample program will be compiled (but not installed). - - -To run:: - - $ cd demo/c++ - $ ./rundemo /usr/local/lib/mapnik - -For more detailed comments have a look in demo/python/rundemo.py - -Have fun! -Artem. diff --git a/demo/c++/rundemo.gyp b/demo/c++/rundemo.gyp new file mode 100644 index 000000000..559b39363 --- /dev/null +++ b/demo/c++/rundemo.gyp @@ -0,0 +1,41 @@ +{ + 'includes': [ 'common.gypi' ], + 'include_dirs': [ + '