Mapnik win32 binaries / Mapnik JNI

1,020 views
Skip to first unread message

nmi

unread,
May 10, 2012, 1:13:06 PM5/10/12
to map...@googlegroups.com
I'm trying to build Mapnik JNI (https://github.com/SpatialInteractive/mapnik-jni) on Windows using the Win32 binary release.  I've found & fixed many issues, currently stuck on the lack of a mapnik.lib file (there was one included in the Mapnik 0.7 windows binary).

Has anyone already done this, or have any suggestions?  Thanks!

Dane Springmeyer

unread,
May 10, 2012, 2:18:59 PM5/10/12
to map...@googlegroups.com
The JNI bindings I think only work against >= Mapnik 2.0.x.

I have branch that I occasionally update (compiling on os x) to track changes in Mapnik master - targeting the upcoming Mapnik 2.1 release: https://github.com/springmeyer/mapnik-jni

Ideally you could compile Mapnik master yourself using the notes at: https://github.com/mapnik/mapnik-packaging

Then if you have changes to get things working we could sync them up.

I should mention however that I don't think anyone has yet tried to build the JNI bindings on windows, so I expect a number of hurdles.

Dane

nmi

unread,
May 11, 2012, 12:14:47 PM5/11/12
to map...@googlegroups.com
I am working with the 2.0.1 Win32 package, and have made some
progress, but the lack of a mapnik.lib file in that distribution is holding
me up.  It was included in the Mapnik 0.7 Win32 binary distributions;
do you know why it was omitted in the 2.x series?

I would rather not need to build Mapnik for Win32 from scratch just to
make the JNI bindings because it is a rather complicated build (and
I'm not a Win32 guy).

If I can get it to work, I'll contribute changes.  It would be great if the
JNI bindings could be built and distributed in the mapnik binary distributions
just as the python bindings are

nmi

unread,
May 12, 2012, 10:36:23 PM5/12/12
to map...@googlegroups.com
With no answer on the .lib question (and seeing that others have asked for it previously)  I attempted to build Mapnik for windows using the instructions found in mapnik-packaging.  The instructions for building the dependencies are very good (below I listed a few issues I found and overcame).  Unfortunately, as has been posted here before there are no instructions on how to build mapnik itself; the build-mapnik.bat file is not complete.  Worse, it is unclear how to use the files in mapnik-packaging/windows.  Many files are related to dependency building and belong at the dev2 top level, other files and the directories seem to need to be moved or added to the standard mapnik directory, but the instructions don't say.

Has anyone been able to figure this out?

------------ Dependency build notes --------------
- install msysgit to c:\Git (install instruct) or c:\msysgit (env setup script)
- zlib @ version 1.2.7 instead of 1.2.5
- an error comes up in libpq build.  ignore?
- inconsistent use of cd %ROOTDIRS%, suggest at top of each new tool build section
- proj4, unzip of grids in packages dir, not dev2 dir
- expat install instructions don't work (bin installer in packages) where to run from
- where to edit name.opt for GDAL? (assume mean nmake.opt)
- curl load command for libsigc++ did not work, had to use browser

Dane Springmeyer

unread,
May 12, 2012, 11:39:28 PM5/12/12
to map...@googlegroups.com, map...@googlegroups.com
Hi. Sounds like you've made some great progress. Thanks a ton for highlighting fixes and unclear points with the windows build steps. While I am maintaining them I've only set them up from scratch once which is why there are gaps. But the process works, including building Mapnik.

Next week I will try to integrate/fix the issues you highlight. Feel free to create issues at the Mapnik packaging github repo for further issues you need cleared up and I will do my best. 

Thanks!

Dane


nmi

unread,
May 14, 2012, 7:45:08 PM5/14/12
to map...@googlegroups.com
After a few bugfixes and figuring out how to move things from mapnik-packaging into the mapnik tree,  I got mapnik to compile under windows.  And the mapnik.lib file is built by the bjam script, so it can be packaged correctly.

I just started looking at the JNI bindings, it seems like a lot of API changes from 2.0.1 to 2.1 (layer, iterators related to features, etc.) so still a long way to go.

xcopy mapnik-packaging\windows\bindings mapnik\bindings /S
xcopy mapnik-packaging\windows\boost-build mapnik\boost-build /S
xcopy mapnik-packaging\windows\demo mapnik\demo /S
xcopy mapnik-packaging\windows\deps mapnik\deps /S
xcopy mapnik-packaging\windows\ltdl mapnik\ltdl /S
xcopy mapnik-packaging\windows\plugins mapnik\plugins /S
xcopy mapnik-packaging\windows\src mapnik\src /S
xcopy mapnik-packaging\windows\tests mapnik\tests /S
xcopy mapnik-packaging\windows\utils mapnik\utils /S

copy mapnik-packaging\windows\Jamroot mapnik
copy mapnik-packaging\windows\boost-build.jam mapnik

add #include <mapnik/image_view.hpp> to image_util.hpp
add #include <mapnik/image_data.hpp> to image_util.hpp

nmi

unread,
May 16, 2012, 5:33:45 PM5/16/12
to map...@googlegroups.com
Now I have the Windows JNI bindings working well enough to initialize and initialize cleanly, working with Mapnik 2.0.1.  Is there a reason why Windows Mapnik is being compiled without MAPNIK_THREADSAFE?

Dane Springmeyer

unread,
May 16, 2012, 7:20:58 PM5/16/12
to map...@googlegroups.com
On May 16, 2012, at 2:33 PM, nmi wrote:

Now I have the Windows JNI bindings working well enough to initialize and initialize cleanly, working with Mapnik 2.0.1.  Is there a reason why Windows Mapnik is being compiled without MAPNIK_THREADSAFE?

It should be being compiled with that flag set. Can you create an issue at https://github.com/mapnik/mapnik-packaging/issues requesting a fix?

Dane

nmi

unread,
May 16, 2012, 7:53:33 PM5/16/12
to map...@googlegroups.com
Upon further review, it looks like the mapnik-jni C code isn't calling the Mapnik isThreadSafe to return correct information, but is depending on mapnik-config to emit MAPNIK_THREADSAFE, which it isn't doing on Windows since I'm not calling it in my build.  Hmmm.

Dane Springmeyer

unread,
Jan 3, 2013, 1:35:14 PM1/3/13
to map...@googlegroups.com

On Jan 3, 2013, at 2:22 AM, nico.g...@gmail.com wrote:

Hello,

I'm currently trying to get the JNI wrapper under a win32 environment.
According to this discussion I'll have to build mapnik myself first and I'm hardly struggling with it.

First the dependencies are hard to find (boost, cairo, ...)
How/where did you find them with the file system structure used in the build_mapnik.bat ?
Did you build them all yourself ?

Yes, see: https://github.com/mapnik/mapnik-packaging/blob/master/windows/building_mapnik_dependencies.md


I am more likely a java guy so I wanted make a detailed procedure for dummies like me to finally post it for the community.
But it seems to be a hard path.

Its not easy, but doable. Just create issues at https://github.com/mapnik/mapnik-packaging/issues for things that are unclear or seen broken.

I've not run through the entire setup for a while, so their may be a few gaps that need filled.


Thanks for any help.

Regards,

Nicolas.

nico.g...@gmail.com

unread,
Jan 4, 2013, 11:41:56 AM1/4/13
to map...@googlegroups.com
Hello Dane,

Ok, the .md file was obvious and I missed it. My bad.
So I followed the instructions (with several modifications) and I think I get the dependencies built ! Yeay !
I'll make an issue as you suggest it with all the things I stumbled over.
Then I'll try to build mapnik and the JNI wrapper.

Nicolas.

nico.g...@gmail.com

unread,
Jan 9, 2013, 9:48:22 AM1/9/13
to map...@googlegroups.com
Hello,

As promised, I submitted an issue on Git : https://github.com/mapnik/mapnik-packaging/issues/67
Hope this will help other people.

Now I'm having a hard time building mapnik :'(
When I try to build it using build_mapnik.bat the build starts. Load of .obj are built until mapnik is built.
While building mapnik lib, I have linkage errors I don't understand (trace below)

Everything else seem to build fine (except for pgsql2sqlite.hpp : error C2039: 'numeric2string': is not member of 'mapnik::sql_utils') but I don't think it has consequences on mapnik itself.

Anyway does anyone have any idea of what's missing to satisfy the linkage issue ?
My dependency builds may be wrong as I had to toy around with it to get everything built, I have no clue... :'(

Thanks for any help

Nicolas.

Error trace :
datasource_cache.obj : error LNK2019: unresolved external symbol "public: class boost::optional<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > > __thiscall mapnik::parameters::get<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > >(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)const " (??$get@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@parameters@mapnik@@QBE?AV?$optional@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@boost@@ABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z)    referenced in function "public: class boost::shared_ptr<class mapnik::datasource> __thiscall mapnik::datasource_cache::create(class mapnik::parameters const &)" (?create@datasource_cache@mapnik@@QAE?AV?$shared_ptr@Vdatasource@mapnik@@@boost@@ABVparameters@2@@Z)
load_map.obj : error LNK2001: unresolved external symbol "public: class boost::optional<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > > __thiscall mapnik::parameters::get<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > >(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)const " (??$get@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@parameters@mapnik@@QBE?AV?$optional@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@boost@@ABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z)
map.obj : error LNK2019: unresolved external symbol "public: __thiscall mapnik::parameters::parameters(void)" (??0parameters@mapnik@@QAE@XZ) referenced in function "public: __thiscall mapnik::Map::Map(void)" (??0Map@mapnik@@QAE@XZ)
load_map.obj : error LNK2001: unresolved external symbol "public: __thiscall mapnik::parameters::parameters(void)" (??0parameters@mapnik@@QAE@XZ)
memory_datasource.obj : error LNK2001: unresolved external symbol "public: __thiscall mapnik::parameters::parameters(void)" (??0parameters@mapnik@@QAE@XZ)
save_map.obj : error LNK2019: unresolved external symbol "bool __cdecl mapnik::filter::generate_image_filters(class std::back_insert_iterator<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > > &,class std::vector<class boost::variant<struct mapnik::filter::blur,struct mapnik::filter::gray,struct mapnik::filter::agg_stack_blur,struct mapnik::filter::emboss,struct mapnik::filter::sharpen,struct mapnik::filter::edge_detect,struct mapnik::filter::sobel,struct mapnik::filter::x_gradient,struct mapnik::filter::y_gradient,struct mapnik::filter::invert,struct boost::detail::variant::void_,struct boost::detail::variant::void_,struct boost::detail::variant::void_,struct boost::detail::variant::void_,struct boost::detail::variant::void_,struct boost::detail::variant::void_,struct boost::detail::variant::void_,struct boost::detail::variant::void_,struct boost::detail::variant::void_,struct boost::detail::variant::void_>,class std::allocator<class boost::variant<struct mapnik::filter::blur,struct mapnik::filter::gray,struct mapnik::filter::agg_stack_blur,struct mapnik::filter::emboss,struct mapnik::filter::sharpen,struct mapnik::filter::edge_detect,struct mapnik::filter::sobel,struct mapnik::filter::x_gradient,struct mapnik::filter::y_gradient,struct mapnik::filter::invert,struct boost::detail::variant::void_,struct boost::detail::variant::void_,struct boost::detail::variant::void_,struct boost::detail::variant::void_,struct boost::detail::variant::void_,struct boost::detail::variant::void_,struct boost::detail::variant::void_,struct boost::detail::variant::void_,struct boost::detail::variant::void_,struct boost::detail::variant::void_> > > const &)" (?generate_image_filters@filter@mapnik@@YA_NAAV?$back_insert_iterator@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@std@@ABV?$vector@V?$variant@Ublur@filter@mapnik@@Ugray@23@Uagg_stack_blur@23@Uemboss@23@Usharpen@23@Uedge_detect@23@Usobel@23@Ux_gradient@23@Uy_gradient@23@Uinvert@23@Uvoid_@0detail@boost@@Uvoid_@0detail@boost@@Uvoid_@0detail@boost@@Uvoid_@0detail@boost@@Uvoid_@0detail@boost@@Uvoid_@0detail@boost@@Uvoid_@0detail@boost@@Uvoid_@0detail@boost@@Uvoid_@0detail@boost@@Uvoid_@0detail@boost@@@boost@@V?$allocator@V?$variant@Ublur@filter@mapnik@@Ugray@23@Uagg_stack_blur@23@Uemboss@23@Usharpen@23@Uedge_detect@23@Usobel@23@Ux_gradient@23@Uy_gradient@23@Uinvert@23@Uvoid_@0detail@boost@@Uvoid_@0detail@boost@@Uvoid_@0detail@boost@@Uvoid_@0detail@boost@@Uvoid_@0detail@boost@@Uvoid_@0detail@boost@@Uvoid_@0detail@boost@@Uvoid_@0detail@boost@@Uvoid_@0detail@boost@@Uvoid_@0detail@boost@@@boost@@@std@@@4@@Z) referenced in function "void __cdecl mapnik::serialize_style(class boost::property_tree::basic_ptree<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,struct std::less<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > > > &,class std::_Tree_const_iterator<class std::_Tree_val<class std::_Tmap_traits<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,class mapnik::feature_type_style,struct std::less<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > >,class std::allocator<struct std::pair<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const ,class mapnik::feature_type_style> >,0> > >,bool)" (?serialize_style@mapnik@@YAXAAV?$basic_ptree@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@V12@U?$less@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@2@@property_tree@boost@@V?$_Tree_const_iterator@V?$_Tree_val@V?$_Tmap_traits@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@Vfeature_type_style@mapnik@@U?$less@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@2@V?$allocator@U?$pair@$$CBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@Vfeature_type_style@mapnik@@@std@@@2@$0A@@std@@@std@@@std@@_N@Z)
feature_style_processor.obj : error LNK2019: unresolved external symbol "public: class boost::optional<double> __thiscall mapnik::parameters::get<double>(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,double const &)const " (??$get@N@parameters@mapnik@@QBE?AV?$optional@N@boost@@ABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@ABN@Z) referenced in function "private: void __thiscall mapnik::feature_style_processor<class mapnik::cairo_renderer<class Cairo::Context> >::apply_to_layer(class mapnik::layer const &,class mapnik::cairo_renderer<class Cairo::Context> &,class mapnik::projection const &,double,class std::set<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,struct std::less<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > >,class std::allocator<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > > > &)" (?apply_to_layer@?$feature_style_processor@V?$cairo_renderer@VContext@Cairo@@@mapnik@@@mapnik@@AAEXABVlayer@2@AAV?$cairo_renderer@VContext@Cairo@@@2@ABVprojection@2@NAAV?$set@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@U?$less@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@2@V?$allocator@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@2@@std@@@Z)
build\src\msvc-10.0\release\threading-multi\mapnik.dll : fatal error LNK1120: 4 unresolved externals

Dane Springmeyer

unread,
Jan 9, 2013, 1:33:33 PM1/9/13
to map...@googlegroups.com
On Jan 9, 2013, at 6:48 AM, nico.g...@gmail.com wrote:

Hello,

As promised, I submitted an issue on Git : https://github.com/mapnik/mapnik-packaging/issues/67
Hope this will help other people.

Fantastic report, thanks so much for doing that. I will integrate the comments and fixes next time I run through the build.

Now I'm having a hard time building mapnik :'(
When I try to build it using build_mapnik.bat the build starts. Load of .obj are built until mapnik is built.
While building mapnik lib, I have linkage errors I don't understand (trace below)

Everything else seem to build fine (except for pgsql2sqlite.hpp : error C2039: 'numeric2string': is not member of 'mapnik::sql_utils') but I don't think it has consequences on mapnik itself.

Anyway does anyone have any idea of what's missing to satisfy the linkage issue ?
My dependency builds may be wrong as I had to toy around with it to get everything built, I have no clue... :'(

It looks like you are very close, but running into recent things I've pushed to master that broke the windows compile.

The last time I built master on windows was a month ago, so for now the easiest thing might be to git checkout this commit:


Dane

Dane Springmeyer

unread,
Jan 10, 2013, 12:18:10 AM1/10/13
to map...@googlegroups.com
Okay, had a chance to build master on windows and got things working, at least for the core lib (I did not attempt to build any bindings). 

Dane

nico.g...@gmail.com

unread,
Jan 11, 2013, 5:45:08 AM1/11/13
to map...@googlegroups.com
Hello Dane,

I tried to build all on master today but without success. (using the build_manik.bat)
(some file not found and skill linkage issues)
So I did a
"git reset --hard 3fd7909ba0aa0f1ce843f8613556dc41bfb1710a"
to check the revision you mentioned and restart the build.
This time only the ogr.input plugin failed but the rest passed. (could not find libexpat.lib, strange as I have it in C:\dev2\Expat 2.1.0\Bin)
Not a big deal as I am not planning to use it.

So now I have a mapnik.dll and mapnik.lib !!!

Next step, the JNI wrapper.

Nicolas.

Dane Springmeyer

unread,
Jan 11, 2013, 10:21:50 AM1/11/13
to map...@googlegroups.com, map...@googlegroups.com
Thanks for the update. Can you post the master issues here or to a new issue? (I though I fixed them all)

Dane

nico.g...@gmail.com

unread,
Jan 14, 2013, 4:59:14 AM1/14/13
to map...@googlegroups.com
Hello,

Posted an new issue https://github.com/mapnik/mapnik-packaging/issues/68
I think it's easier to read on Git.

For the JNI wrapper I'm stuck as there are no win32 makefile.
I understood that I need a mapnik-jni.dll in order to get it working.
This dll might be build against the sources of JNI project, I think, but I don't know how to do that.
Still searching but if you have any tip I take it ! :)

In the read-me, I read this
""Make sure that the mapnik-config program is on your path and is the one you want to be linking against""
I've never seen any "mapnik-config program" it's confusing me.

Nicolas

nmi

unread,
Jan 14, 2013, 11:30:22 AM1/14/13
to map...@googlegroups.com
I also had a great deal of trouble generating win32 binaries for Mapnik 2.0 and it's JNI wrapper - I eventually got it right, but it is very difficult. I haven't moved on to current versions because of the time required. I think the great Win32 capabilities would be more widely used if every user didn't have to recreate it from source.  Dane, would it be possible for you to post the binaries you generate in your testing?

Philip Howarth

unread,
Jan 14, 2013, 11:53:34 AM1/14/13
to map...@googlegroups.com
I feel sure that the difficulties that many folk experience in implementing Mapnik solutions on Windows based systems are a not-insignificant barrier to adoption.  Having ready-made binaries would be a great help - but someone has to spend the time and energy in creating/testing/managing them. I wish I could help, but I don't have the skills.

Clearly the majority of implementations use some form of Unix - but it is surprising to note that this Wikipedia entry reckons that about a third of all servers use a Windows based OS (and a staggering 91+% of desktops/laptops/netbooks!) That must equate to a lot of potential users - despite the probable bias towards 'nix by the developer community.

Perhaps those of us stuck in a Windows universe need to offer tangible incentives (not just words of encouragement) - beer, flowers, money...?

    Philip
--
Philip Howarth
Cambridge UK
email: Phi...@Howarth.name

Dane Springmeyer

unread,
Jan 14, 2013, 4:54:42 PM1/14/13
to map...@googlegroups.com
On Jan 14, 2013, at 1:59 AM, nico.g...@gmail.com wrote:

Hello,

Posted an new issue https://github.com/mapnik/mapnik-packaging/issues/68

Thanks, all those issues should be fixed now. Can you try again?

For the JNI wrapper I'm stuck as there are no win32 makefile.

Right. And I have too little experience myself with java on windows to know quite how to tackle this right off.

NMI must have written one (and just responded to this thread) so i will follow up to his post.

In the read-me, I read this
""Make sure that the mapnik-config program is on your path and is the one you want to be linking against""
I've never seen any "mapnik-config program" it's confusing me.


Right, mapnik-config is a bash/shell program that only works on Unix system to make it easy to see what compile/link flags are needed. A mapnik-config.bat could likely be written to emulate it. Feel free to create a ticket on this.

Dane Springmeyer

unread,
Jan 14, 2013, 5:02:52 PM1/14/13
to map...@googlegroups.com
On Jan 14, 2013, at 8:30 AM, nmi wrote:

I also had a great deal of trouble generating win32 binaries for Mapnik 2.0

One question - how did you build the jni bindings? Did you make visual studio files or did you modify the existing scripts to work with windows?

Also, the major headache you ran into (if I recall correctly) was due to a bug in the java bindings. The ltdl workaround you helped brief me on (thanks again for that) finally clicked and we recently both fixed that bug and changed the API in latest mapnik to ensure that this mis-usage does not occur again.


and it's JNI wrapper - I eventually got it right, but it is very difficult. I haven't moved on to current versions because of the time required.

I think latest master of mapnik + master of my jni fork should work much better now:


My hope is that with the upcoming Mapnik 2.2 release we'll actually, for the first time, have stable versions that play well together on windows.

I think the great Win32 capabilities would be more widely used if every user didn't have to recreate it from source.  Dane, would it be possible for you to post the binaries you generate in your testing?

Yes. Also see http://mapbox.com/tilemill/, which includes mapnik.dll inside and a variety of plugins.

Dane

Dane Springmeyer

unread,
Jan 14, 2013, 5:13:11 PM1/14/13
to map...@googlegroups.com
On Jan 14, 2013, at 8:53 AM, Philip Howarth wrote:

I feel sure that the difficulties that many folk experience in implementing Mapnik solutions on Windows based systems are a not-insignificant barrier to adoption.

Yes, agree, its a major barrier that we really should not have.

Having ready-made binaries would be a great help - but someone has to spend the time and energy in creating/testing/managing them.

Every month or so I try to update the mapnik core library code so that it builds with msvc 2010. I plan to try to get the python bindings built (and perhaps other bindings) and to provide binaries for the next release. However the work it takes me to get a Mapnik release out in general is huge, and due to my focus on linux and osx, windows often falls off my list.

However what is different now is that I've cultivated a decent set of scripts that anyone can run (what Nico is helping catch errors in: https://github.com/mapnik/mapnik-packaging/). So, if ever someone wants to help build and provide binaries I'm in a better position to help them help doing that.

I wish I could help, but I don't have the skills.

I hear you. But thanks for your encouragement.

Clearly the majority of implementations use some form of Unix - but it is surprising to note that this Wikipedia entry reckons that about a third of all servers use a Windows based OS (and a staggering 91+% of desktops/laptops/netbooks!) That must equate to a lot of potential users - despite the probable bias towards 'nix by the developer community.

Perhaps those of us stuck in a Windows universe need to offer tangible incentives (not just words of encouragement) - beer, flowers, money...?

I think we need:

1) Mapnik core developers committed to ensuring Mapnik master and a stable release actually compiles on Windows with msvc 2010 (in the future 2012?)
2) Mapnik bindings also need to be kept up to date

I'm working on those ^^, but I could really use help with:

3) People who know and use windows helping test the build scripts on clean/fresh windows boxes (my dev environment is really crufty and is a pain to use: Win7 in an OSX VirtualBox image) (Nico as part of this thread is helping here and it's awesome)
4) Someone to step up who can volunteer to do the windows official binaries when we hit stable releases.

Ideally the ^^ #4 would not be me and if anyone is to get flowers or beer or money it should likely be that person :)

Dane

nico.g...@gmail.com

unread,
Jan 15, 2013, 5:56:45 AM1/15/13
to map...@googlegroups.com
Hello,

First, about building mapnik on master, ... *drum roll* ... it works !!! :D
I pulled lastest mapnik and mapnik-packaging master repositories and made a full build of mapnik. (I did not rebuild the required libraries but I think it's still working with the .md file and the notes I issued previously)

On small thing though, Expat has to be installed in it's default install directory (C:\Program Files (x86)\Expat 2.1.0) otherwise the ogr plugin won't find the libexpat.lib. (I installed it under C:\dev2\Expat 2.1.0 to have it with all other dependencies but it was a bad idea)
So it's a 100% successful build ! :D

Second about JNI ...
I'd love to have NMI's instructions to build the JNI wrapper.
That would be an awesome share for all fellow windows users !
I'll keep searching at my side but I have a lot to catch up with JNI and makefiles learning.

nmi

unread,
Jan 15, 2013, 9:00:44 AM1/15/13
to map...@googlegroups.com
I built the JNI bindings using MSVC2010 express and a visual studio setup (like Dane, Win7 in an OSX VirtualBox image).  I seem to recall thinking the scripts were really far off when I looked at them, which is why I went with the VS approach.  This was last May so things may have changed.

As Dane says, the final big problem was getting the ltdl emulation library to load plugins, but I thought his version of my fix was in https://github.com/mapnik/mapnik/issues/1033

The win32 build process took so much time that I've avoided looking at it again, even though I really should so I can release a cool Java tile server I wrote...

nico.g...@gmail.com

unread,
Jan 16, 2013, 10:08:38 AM1/16/13
to map...@googlegroups.com
Hello,

I followed your hint trying to build through MSVC2010 express, but I'm stuck with compile errors going out of my understanding.
Here's what I did
- create a new empty project
- putting /mapnik-jni/csrc/ source files into the project source folders
    - the *.cpp go to "Source files"
    - the mapnikjni.h goes to "Header files"
- adding other dependencies
    - right-click on the project -> properties -> C/C++ -> General
    - in the "Other include directories" I added the path to include directories :
        "E:\Java32\jdk1.7.0_10\include\win32" (needed for jni)
        "E:\Java32\jdk1.7.0_10\include" (needed for jni)
        "C:\dev2\libtool\include" (required)
        "C:\dev2\proj\src" (mapnik dependency)
        "C:\dev2\icu\include" (mapnik dependency)
        "C:\dev2\freetype\include" (mapnik dependency)
        "C:\dev2\boost-49-vc100\include\boost-1_49" (mapnik dependency)
        "C:\mapnik-2.1\include\mapnik\agg" (mapnik dependency)
        "C:\mapnik-2.1\include" (mapnik dependency)
        ... probably some others but I added them compile after compile when the compiler complained about missing header files.

at this state when I try to build I have dozens of warnings (nothing unusual) and here are the first errors :

I don't get what's wrong at all, I'm not even sure I understand these
If you have any more hint, I gladly take it :D

btw, it's precisely a java tile server I am also trying to create :D

...
e:\program files (x86)\microsoft visual studio 10.0\vc\include\utility(167): error C2079: 'std::_Pair_base<_Ty1,_Ty2>::second' uses a class of 'mapnik::feature_type_style' undefined
          with
          [
              _Ty1=const std::string,
              _Ty2=mapnik::feature_type_style
          ]
          e:\program files (x86)\microsoft visual studio 10.0\vc\include\utility(174) : see reference to class template instantiation 'std::_Pair_base<_Ty1,_Ty2>' being compiled
          with
          [
              _Ty1=const std::string,
              _Ty2=mapnik::feature_type_style
          ]
          e:\_work\mapnik-2.1\mapnik-jni\csrc\class_map.cpp(370) : see reference to class template instantiation 'std::pair<_Ty1,_Ty2>' being compiled
          with
          [
              _Ty1=const std::string,
              _Ty2=mapnik::feature_type_style
          ]
...
e:\_work\mapnik-2.1\mapnik-jni\csrc\class_map.cpp(394): error C2514: 'mapnik::feature_type_style' : the class doesn't have any constructor
          c:\mapnik-2.1\include\mapnik\map.hpp(40) : se declaration of 'mapnik::feature_type_style'
...
e:\_work\mapnik-2.1\mapnik-jni\csrc\class_datasource.cpp(66): error C2039: 'bind' : is not member of 'mapnik::datasource'
          c:\mapnik-2.1\include\mapnik\datasource.hpp(72) : see delcaration of 'mapnik::datasource'
...

nmi

unread,
Jan 16, 2013, 11:20:57 AM1/16/13
to map...@googlegroups.com
MSVC++ compile errors aren't intended to be understood :-)

I haven't looked at post 2.0 Mapnik or Mapnik JNI, but my command line for the JNI compile was:

/I"C:\dev2\mapnik\ltdl" /I"C:\dev2\freetype\include" /I"C:\dev2\freetype\include\freetype" /I"C:\dev2\proj\src" /I"C:\dev2\icu\include" /I"C:\dev2\boost-49-vc100\include\boost-1_49" /I"C:\mapnik-2.0\include" /I"C:\mapnik-2.0\include\mapnik" /I"C:\Program Files (x86)\Java\jdk1.6.0_32\include" /I"C:\Program Files (x86)\Java\jdk1.6.0_32\include\win32" /Zi /nologo /W3 /WX- /O2 /Oi /Oy- /D "MAPNIK_THREADSAFE" /D "HAVE_LIBXML2" /D "HAVE_JPEG" /D "HAVE_CAIROWIN32" /D "NDEBUG" /D "_WINDOWS" /D "_USRDLL" /D "MAPNIKJNI_EXPORTS" /D "_WINDLL" /D "_UNICODE" /D "UNICODE" /Gm- /EHsc /GS /Gy /fp:precise /Zc:wchar_t /Zc:forScope /Fp"Release\mapnik-jni.pch" /Fa"Release\" /Fo"Release\" /Fd"Release\vc100.pdb" /Gd /analyze- /errorReport:queue 

Dane Springmeyer

unread,
Jan 16, 2013, 12:08:52 PM1/16/13
to map...@googlegroups.com
It looks like you may have the wrong/old repo. Which github repo did you clone?

nico.g...@gmail.com

unread,
Jan 17, 2013, 3:26:36 AM1/17/13
to map...@googlegroups.com
Hello,

Indeed, Dane !
I used your repo (https://github.com/springmeyer/mapnik-jni) but I think I cloned it few hours before your last commit.
So now with the last version of it (hash: 9d6fb344b6d902fc3155072e3ea30add5b93b26e) and nmi's compilation parameters I could compile the /csrc/mapnikjni.cpp
However I don't have the dll yet. I have to play a bit with .libs linkage but I think I can find how to do it. Otherwise I might abuse of your wisdom and kindness again ^^.
As soon as I have the DLL, be sure I'll share a complete build procedure for windows.

Nico.

nico.g...@gmail.com

unread,
Jan 17, 2013, 9:10:54 AM1/17/13
to map...@googlegroups.com
Hello,

Unfortunately I could not fix all linkage errors.
But as I have already done few steps, I created an issue with what I did.
https://github.com/springmeyer/mapnik-jni/issues/3
Hope this could be a base for the future build under Windows

The linkage error I'm facing right now are at the end of this issue.
If you have any idea ...

NMI, maybe you have what I need in the linker command line arguments, could you post it ?

Thanks for all the help your giving me out here !

Nico.

nmi

unread,
Jan 17, 2013, 9:38:46 AM1/17/13
to map...@googlegroups.com
This is what worked for 2.0

/OUT:"C:\Users\mike\Documents\Visual Studio 2010\Projects\mapnik-jni\Release\mapnik-jni.dll" /INCREMENTAL /NOLOGO /LIBPATH:"C:\dev2\boost-49-vc100\lib" /LIBPATH:"C:\mapnik-2.0\lib" /DLL "mapnik.lib" "kernel32.lib" "user32.lib" "gdi32.lib" "winspool.lib" "comdlg32.lib" "advapi32.lib" "shell32.lib" "ole32.lib" "oleaut32.lib" "uuid.lib" "odbc32.lib" "odbccp32.lib" /MANIFEST /ManifestFile:"Release\mapnik-jni.dll.intermediate.manifest" /ALLOWISOLATION /MANIFESTUAC:"level='asInvoker' uiAccess='false'" /DEBUG /PDB:"C:\Users\mike\Documents\Visual Studio 2010\Projects\mapnik-jni\Release\mapnik-jni.pdb" /SUBSYSTEM:WINDOWS /OPT:REF /OPT:ICF /PGD:"C:\Users\mike\Documents\Visual Studio 2010\Projects\mapnik-jni\Release\mapnik-jni.pgd" /TLBID:1 /DYNAMICBASE /NXCOMPAT /MACHINE:X86 /ERRORREPORT:QUEUE 

nico.g...@gmail.com

unread,
Jan 17, 2013, 10:00:42 AM1/17/13
to map...@googlegroups.com
Thanks for the quick answer,

Same parameter are not working for me :s

There's juste one thing, do you remember moving files around, especially the mapnik.lib ?
I think you might have moved it in "C:\mapnik-2.0\lib" as this path is in your LIBPATH.
As I only have mapnik.dll and it's dependencies dll in there maybe you moved there something more ?

Nico.

nmi

unread,
Jan 17, 2013, 10:49:56 AM1/17/13
to map...@googlegroups.com
Yes, I have a mapnik installation directory with bin, lib, and include.  The lib subdir has:
cairo.dll
cairomm-vc100-1_0.dll
icudt48.dll
icuuc48.dll
libexpat.dll
libxml2.dll
mapnik
mapnik-jni.dll
mapnik-jni.jar
mapnik-jni.lib
mapnik.dll
mapnik.lib
proj.dll
sigc-vc100-2_0.dll

The mapnik subdir in lib has the fonts and input subdirs (for fonts and plugins)

nico.g...@gmail.com

unread,
Jan 18, 2013, 5:51:10 AM1/18/13
to map...@googlegroups.com
Thanks a lot NMI,

I tried with the same configuration but still the same linkage failures.
Dan answered the issue I posted, he thinks that some modifications to mapnik's core might be needed.

Thank you again so much for the help you're giving.

(I'll be on holiday next week, but I'll get back on this at my return)

Nico.

Dane Springmeyer

unread,
Jan 18, 2013, 3:35:51 PM1/18/13
to map...@googlegroups.com
On Jan 18, 2013, at 2:51 AM, nico.g...@gmail.com wrote:

Thanks a lot NMI,

I tried with the same configuration but still the same linkage failures.
Dan answered the issue I posted, he thinks that some modifications to mapnik's core might be needed.

Yes, MAPNIK_DECL is needed to expose the symbols of a few classes it appears that are used by the bindings (and not other bindings).

This is an easy fix (and one I frequently make for windows) but it will require me getting set up with Java on windows. Given that I've never actually used Java myself, on any platform, this could take a bit.


Thank you again so much for the help you're giving.

(I'll be on holiday next week, but I'll get back on this at my return)

Cool, that will buy me some time to learn ant/java setup on windows :) Ping me when you are back.

I'm confident this can be made to work.

Dane

nico.g...@gmail.com

unread,
Jan 28, 2013, 4:03:53 AM1/28/13
to map...@googlegroups.com
Hi

Back from holiday !

So, have you already got started with java ?
I think the easiest and quickest way is to use Eclipse IDE.
It includes Ant and is quite easy to use.

I can probably help you with the java environment, though my knowledge of Ant and JNI are short.

Nico.

Dane Springmeyer

unread,
Jan 29, 2013, 2:21:33 PM1/29/13
to map...@googlegroups.com

On Jan 28, 2013, at 4:03 AM, nico.g...@gmail.com wrote:

Back from holiday !

So, have you already got started with java ?
I think the easiest and quickest way is to use Eclipse IDE. 
It includes Ant and is quite easy to use.

I can probably help you with the java environment, though my knowledge of Ant and JNI are short.

Hi, Sorry have not had a chance to work on this yet. I think all that is needed is a visual studio file to compile the code in csrc. I'm thinking about writing a gyp file to make this easy to author the visual studio file and to run it from the command line.

Dane

nico.g...@gmail.com

unread,
Jan 30, 2013, 7:38:43 AM1/30/13
to map...@googlegroups.com
Hi Dane,

Ok no prob.

Indeed to build the source in csrc, only visual studio is required.
Java only comes as an overlay and isn't needed.

Nico.
Reply all
Reply to author
Forward
0 new messages