add details for how to build rundemo.cpp standalone on windows with gyp
This commit is contained in:
parent
019873a9d2
commit
5239bef595
5 changed files with 161 additions and 21 deletions
|
@ -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)
|
LDFLAGS = $(shell mapnik-config --libs --dep-libs --ldflags)
|
||||||
|
|
||||||
OBJ = rundemo.o
|
OBJ = rundemo.o
|
||||||
|
@ -13,8 +13,15 @@ $(BIN) : $(OBJ)
|
||||||
.c.o :
|
.c.o :
|
||||||
$(CXX) -c $(CXXFLAGS) $<
|
$(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
|
.PHONY : clean
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
rm -f $(OBJ)
|
rm -f $(OBJ)
|
||||||
rm -f $(BIN)
|
rm -f $(BIN)
|
||||||
|
rm -f ./build
|
70
demo/c++/README.md
Normal file
70
demo/c++/README.md
Normal file
|
@ -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
|
42
demo/c++/common.gypi
Normal file
42
demo/c++/common.gypi
Normal file
|
@ -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' ]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -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.
|
|
41
demo/c++/rundemo.gyp
Normal file
41
demo/c++/rundemo.gyp
Normal file
|
@ -0,0 +1,41 @@
|
||||||
|
{
|
||||||
|
'includes': [ 'common.gypi' ],
|
||||||
|
'include_dirs': [
|
||||||
|
'<!@(mapnik-config --includes)',
|
||||||
|
'<!@(mapnik-config --dep-includes)',
|
||||||
|
],
|
||||||
|
'defines': [
|
||||||
|
'<!@(mapnik-config --defines)',
|
||||||
|
],
|
||||||
|
'targets': [
|
||||||
|
{
|
||||||
|
'target_name': 'rundemo',
|
||||||
|
'type': 'executable',
|
||||||
|
'sources': [
|
||||||
|
'rundemo.cpp',
|
||||||
|
],
|
||||||
|
'conditions': [
|
||||||
|
[ 'OS=="mac"', {
|
||||||
|
'libraries': [
|
||||||
|
'-lmapnik',
|
||||||
|
'-undefined dynamic_lookup'
|
||||||
|
],
|
||||||
|
'xcode_settings': {
|
||||||
|
'OTHER_CPLUSPLUSFLAGS':[
|
||||||
|
'<!@(mapnik-config --cflags)'
|
||||||
|
],
|
||||||
|
'GCC_ENABLE_CPP_RTTI': 'YES',
|
||||||
|
'GCC_ENABLE_CPP_EXCEPTIONS': 'YES'
|
||||||
|
}
|
||||||
|
}],
|
||||||
|
[ 'OS=="win"', {
|
||||||
|
'msvs_settings': {
|
||||||
|
'AdditionalLibraryDirectories': [
|
||||||
|
'<!@(mapnik-config --ldflags)'
|
||||||
|
],
|
||||||
|
}
|
||||||
|
}]
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
}
|
Loading…
Reference in a new issue