Building OpenLayers 3 on Windows (Update: Working!)

Building OpenLayers 3 on Windows (Update: Working!)

Let me just start with the bad news, I haven’t been able to get this thing to work just yet. (Update: it works!) I will hopefully get there soon. For now I will just write down all the steps I took to get this far.


First off, OpenLayers 3 is currently in Beta. It’s starting to look great, but some newer features I want to use didn’t make the beta just yet. So, I boldly started getting a source snapshot. OL3 is a bit different from Ol2, as you now really have to build it to use it. Ol2 could just be grabbed, modified and used. Then, if you choose to, you can run a python script to minify it.

The OL3 team made a nice developer guide on their GitHub Wiki. However, it’s written with Linux users in mind. I’m a Windows user, a .NET programmer, so I do not run a Linux machine for development purposes. I do want to be a early OL3 adopter, so I tried to get it running, or… building… on Windows.

So the Developer Guide starts with some requirements, so for sake of arguments, I will assume Windows will need all those same tools:

Windows Path changes

So, there are some things to remember. OL3 development team does not use Windows. I repeat, they don’t use windows. Appearantly, neither do Python developers. To install the regex python plugin (will get to that later) you will need to fool it that you are running visual studio 9.0, aka 2008.

Create an envirmental variable named “VS90COMNTOOLS” and point it to your visual studio: common7\tools folder. For instance “c:\program files (x86)\Microsoft Visual Studio 11.0\Common7\Tools” for Microsoft Visual Studio 2012. if you forget this step, you will get an error saying it cannot find “vcvarsall.bat”. Strange enough, the variable should not point to the folder where it resides. (Microsoft Visual Studio 11.0\VC)

Now, you will need to add that VC folder to you PATH file, as well as you Python install folder.

Edit: Then, add the path to git.exe to your path as well.

Installing Python plugins on Windows

This was new for me as well, so I might as well put down how to do it.

First, the OL3 build script has some dependancies:

  1. Closure_linter
  2. SetupTools (requirement for Pystache)
  3. Pystache
  4. Regex

Download them all and unpack them to a place you can remember. Then open a command prompt and run this command in each of the 4 unpacked plugin folders (in the order of the download list above):

python install

You should see a lot of text running by. As long as it doesn’t end with an error line, you’re good.

What’s next?

According to the developer guide, we should be good to build now:

Open a command prompt and navigate to your local ol3 copy. (could be a clone of your fork, or a downloaded .zip with source)

Then you should be able to run:

python build

I explicitly said “able to run”, as this ended with:

[sourcecode language=”bash”]Traceback (most recent call last):
File “”, line 83, in
‘%(GIT)s’, ‘rev-parse’, ‘–abbrev-ref’, ‘HEAD’).strip()
File “D:\openlayers\3.0 12 december\”, line 348, in output
return check_output(args)
File “c:\python27\lib\”, line 566, in check_output
process = Popen(stdout=PIPE, *popenargs, **kwargs)
File “c:\python27\lib\”, line 709, in __init__
errread, errwrite)
File “c:\python27\lib\”, line 957, in _execute_child
WindowsError: [Error 2] The system cannot find the file specified[/sourcecode]

So, it ends here? Will Window’s users be shunned from OpenLayers 3 forever? I hope not. If you see I missed something, please tell me in the comments. I will update this article when I find more details.

Update 11.00: one step further.

Just got a message from Bart v/d Eijnden (Boundless & OGC Board member) on Twitter asking me to check for GIT in path. I didn’t have it in path, so I added that too above. Onfortunately, I am confronted with another error on not having a .GIT. It’s a bit strange to have a dependancy on a build script on needing a specific source control, but I will pull the code through git to test it out. Will update again later.

Update 11.30: succes!

After getting git in my path, I stumbled on some Java errors. Apearantly, the build script doesn’t seem to listen to the JAVA_HOME environmental variable. (or I made a typo somewhere…) I copied my JDK\JRE\bin\server folder to the JRE\bin folder the build script was looking at, and now the build seems to work! Now I can finally test out the new stuff built after beta.