There are many reasons you might want to build Subversion yourself rather than use a binary distribution such as CollabNet’s certified Subversion Command Line Client or CollabNet Subversion Edge (available here http://www.open.collab.net/products/subversion/getit.html). One common reason is the need for a debug build to track down potential problems. Another is the desire to submit a patch to the open source community to implement new functionality or perhaps fix that bug you just tracked down.
Compiling Subversion on Linux is fairly straightforward and the community’s INSTALL document (http://svn.apache.org/repos/asf/subversion/trunk/INSTALL) is typically sufficient. For Windows developers though, the task is more complicated, particularly when it comes to Subversion’s dependencies. The INSTALL document covers the basics, and is an essential read, but depending on one’s environment and experience, the build process can be a bit frustrating.
When I build a new machine for Subversion development I normally “cheat” a bit (o.k., a lot) and copy the build configuration from one of my existing boxes. In fact, the five machines I’ve done development on since 2006 all have quite a bit of “DNA” in common — I hadn’t truly put together a development box “from scratch” since I started working on Subversion.
So recently, when a customer wanted some pointers on building Subversion so they could potentially contribute a patch and a coworker was having some build problems and my employer issued me a new laptop, I knew it was time to do a build from the ground up.
This post is an offshoot of that effort. Keep in mind it isn’t meant as a replacement to the INSTALL document, but rather a demonstration of it. It walks through a relatively simple build of Apache, Subversion, and several dependencies for both on a Windows 7 machine using Microsoft’s Visual Studio 2008. It is not intended as the authoritative source for building Subversion on Windows; you may want something simpler (e.g. no Apache, no serf, no neon, no bdb) or you may want something more involved (e.g. building some of the Subversion bindings for Python, Java, Perl, etc.) It is meant as a starting point for those who have had trouble building Subversion on Windows, those who don’t have a lot of Windows development experience, or those who are simply pressed for time and just want “something that works”.
Before You Start
- If you haven’t read the INSTALL document, I strongly recommend that you do, though it isn’t absolutely necessary.
- This post assumes you are using Visual Studio 2008 on a Windows 7 machine. The instructions may work with versions of Visual Studio newer than VS 6.0 and with Windows Vista or XP, but those variants were not tested. It definitely won’t work with Visual Studio 2010, I have confirmed that. This is not to say you can’t use VS 2010, the AnkhSVN team (http://ankhsvn.open.collab.net/) has successfully used it, but you will experience problems following this walk-through.
- This post assumes your install drive root is ‘C:’ and you are doing all your Subversion related work in C:SVN. It also assumes you install any required tools to their default locations. You’ll obviously need to adjust the paths to fit your own environment.
- Each requirement for building Subversion and Apache listed has a version number after it, e.g.: Zlib (1.2.4)’. This is the version of the dependency I used. Everything may work fine for you with a newer or older version, but your mileage may vary.
- In all the command line build examples shown in this post I am using the ‘Visual Studio 2008 Command Prompt’ rather than the “generic” command prompt. By default this installs to “C:Program FilesMicrosoft Visual Studio 9.0VCvcvarsall.bat”. It tweaks %PATH% and other environment variables to find VS2008 components.
A) Tools, Utilities, and Dependencies
A1) Visual Studio 2008
You don’t need the full install, just the C++ tools. You will need to install Service Pack 1 for VS2008 or you may experience linking errors when building Subversion.
Note: Windows Update did not list SP1 as a recommended or even optional update on Windows 7. If you have the same problem you can download it directly from Microsoft (http://www.microsoft.com/downloads/en/confirmation.aspx?familyId=fbee1648-7106-44a7-9649-6d9f6d58056e&displayLang=en).
A2) Get a Bootstrap Subversion Client
You need a working svn client for this walk-through. CollabNet provides free binaries here http://www.open.collab.net/downloads/subversion/.
A3) Perl (5.12.2)
Download ActiveState Perl (http://www.activestate.com/activeperl/downloads) and install it.
A4) Python (2.6.6)
Download ActiveState Python (http://www.activestate.com/activepython/downloads) and install it.
A5) Install awk
See the section on awk in Apache’s httpd 2.2 documentation (http://httpd.apache.org/docs/2.2/platform/win_compiling.html) and install it per those directions.
A6) Zlib (1.2.4)
The latest version of zlib, 1.2.5, has known problems (http://svn.haxx.se/dev/archive-2010-11/0037.shtml), so we use a slightly older version.
Download zlib 1.2.4 (http://sourceforge.net/projects/libpng/files/) and unzip it into C:SVNzlib.
A7) OpenSSL (0.9.8q)
Download the latest* openssl source (http://www.openssl.org/source/) and place it in C:SVNopenssl.
Build and test OpenSSL with these commands:
C:SVNopenssl>perl Configure VC-WIN32 C:SVNopenssl>msdo_ms.bat
C:SVNopenssl>nmake -F msntdll.mak
C:SVNopenssl>nmake -F msntdll.mak test
Add C:SVNopensslout32dll to your %PATH%.
* The latest OpenSSL is actually 1.0.0c, but it doesn’t export SSL_session_cmp which Subversion requires.
A8) Neon (0.29.5)
Use the Subversion command line client you installed in step A2 to checkout the latest release of neon:
C:SVN>svn co http://svn.webdav.org/repos/projects/neon/tags/0.29.5/ neon
Take a few steps so Subversion’s build scripts will build neon. First, create a version file:
Second, create a config file:
C:SVNneon>copy config.hw.in config.hw
Lastly, edit C:SVNneonconfig.hw to define the version of Neon:
-#define NEON_VERSION "@VERSION@"
-#define NE_VERSION_MAJOR (@MAJOR@)
-#define NE_VERSION_MINOR (@MINOR@)
+#define NEON_VERSION "0.29.5"
+#define NE_VERSION_MAJOR (0)
+#define NE_VERSION_MINOR (29)
A9) Serf (0.7.0)
Checkout the latest version of serf:
C:SVN>svn co http://serf.googlecode.com/svn/tags/0.7.0 C:SVNserf
A10) SQLite (3.7.3)
Download the latest sqlite amalgamation (http://www.sqlite.org/download.html) and put it in C:SVNsqlite.
A11) Berkeley DB (4.8.30)
Download the latest version of BDB 4.x (http://download.oracle.com/berkeley-db/db-4.8.30.zip). Unzip the sources into C:SVNbdb.
Note: If you use Windows 7’s built in zip extraction tool, the provided VS Solution file C:SVNbdbbuild_windowsBerkeley_DB.sln (and several other files) are set as read only, so remove the ‘read only’ attribute from C:SVNbdb and all it’s sub-folders before proceeding.
Open the file C:/SVN/bdb/docs/programmer_reference/build_win.html in your browser and follow the build directions for VS2008 and build the [Debug | Release] x [Win32] variants.
Move the resulting *.lib and *.dll files to the locations Subversion’s build scripts will expect to find them:
C:SVNbdb>copy build_windowsWin32Debuglibdb48d.dll bin
C:SVNbdb>copy build_windowsWin32Releaselibdb48.dll bin
C:SVNbdb>copy build_windowsWin32Releaselibdb48.lib lib
C:SVNbdb>copy build_windowsWin32Debuglibdb48d.lib lib
In the VS2008 IDE’s Tools->Options->Projects and Solutions->C++ Directories->Executable Files list, add the following path:
In the same window add C:SVNbdblib to the Projects and Solutions->C++ Directories->Library Files list:
Lastly, add C:SVNbdbbuild_windows to the Projects and Solutions->C++ Directories->Include files list:
B1) Get the Apache Source (2.2.16)
Note: The latest HTTPD release, 2.2.17, has known problems (http://svn.haxx.se/dev/archive-2010-11/0037.shtml), so we use 2.2.16.
Download the official httpd distribution (http://archive.apache.org/dist/httpd/httpd-2.2.16-win32-src.zip) and unzip it in C:SVNhttpd-2.2.16.
B2) Configure Apache
Convert the Apache *.dsp files as described in the section “There is a flaw in the .vcproj conversion of .dsp through Visual Studio 2005 SP1” of Apache’s httpd 2.2 documentation (http://httpd.apache.org/docs/2.2/platform/win_compiling.html):
C:SVNhttpd-2.2.16>perl srclibaprbuildcvtdsp.pl -2005
Note: Despite the ‘-2005’, this applies to VS 2008 too.
Edit C:SVNhttpd-2.2.16srclibapr-utilincludeapu.hw to signal that we will build apr-util with BDB support:
-#define APU_HAVE_DB 0
+#define APU_HAVE_DB 1
Note that is ‘apu.hw’, not apu.h! The latter is generated from the former.
Open C:SVNhttpd-2.2.16Apache.dsw with the Visual Studio IDE. When asked if you want to convert httpd.dsp to the current Visual C++ project format, select ‘Yes to All’.
By default the resulting Visual Studio solution will try to link apr_dbm_db against bdb4.7, so update the additional dependencies list to point to libdb48.lib and libdb48d.lib for the Release and Debug configurations respectively:
The httxt2dbm and htdbm projects need the libdb48(d).dll’s added as additional dependencies, so do that as well.
B3) Build Apache
Now build the Release or Debug configuration of the BuildBin project. If you get errors like these:
5>apr : error PRJ0008 : Could not delete file 'c:SVNhttpd-2.2.16srclibaprincludeapr.h'.
8>LINK : fatal error LNK1181: cannot open input file '..srclibaprlibdapr-1.lib'
Try building again. You might also try temporarily disabling any virus scanners you are running.
Once you have successfully built the BuildBin project, build the desired configuration of the InstallBin project to actually install the server. By default this installs Apache in C:Apache22.
C1) Get Subversion
Checkout Subversion’s trunk code:
C:SVN>svn co https://svn.apache.org/repos/asf/subversion/trunk src-trunk
C2) Configure Subversion
Run gen-make.py (adjusting the paths in the various options as necessary to reflect your setup):
C:SVNsrc-trunk>gen-make.py -t vcproj --vsnet-version=2008 --with-berkeley-db=C:SVNbdb --with-httpd=C:SVNhttpd-2.2.16 --with-neon C:SVNneon --with-serf=C:SVNserf --with-sqlite=C:SVNsqlite --with-zlib=C:SVNzlib --with-openssl=C:SVNopenssl
C3) Build Subversion
Build your desired configuration of Subversion, we'll do a release build here:
C:SVNsrc-trunk>msbuild subversion_vcnet.sln/t:__ALL_TESTS__ /p:Configuration=Release
D) Run The Test Suite
D1) Run the Local Tests
Adjust your path so libapriconv-1.dll can be found:
Run the win-tests.py script to test Subversion over file:///access with a FSFS back-end (the script should locate all the other required dlls and executables):
C:SVNsrc-trunk>win-tests.py --release --cleanup --parallel
* While Subversion doesn’t use libapriconv-1.dll, it does require libaprutil-1.dll, which requires iconv.
D2) Run the Tests with Apache
You can also use the win-tests.py script to configure and start the Apache server and then run the test suite against it:
C:SVNsrc-trunk>win-tests.py -r -c --httpd-dir=C:Apache22 --httpd-daemon
Hopefully by this point you are successfully running the Subversion test suite. If you have specific questions about the details of this post feel free to post your questions here. More general questions about building Subversion should be directed to the email@example.com mailing list or the irc.freenode.net channel #svn.