Over the weekend, I had to do a new build of the mod_xsendfile module since I put a custom fix for theissue I was having. As it turns out, however, compiling Apache modules on Windows is not very straightforward at all (Linux, on the other hand, you just simply type apxs2 -cia some_apache_module.c).
After lots of Googling and trying different approaches, I finally got it to work by doing the following using Microsoft Visual Studio. Note that I only tried this on the mod_xsendfile module but I’m assuming this will work for building other Apache modules as well:
You can download Microsoft Visual Studio Express for free here if you don’t have VS (I used VS 2008 Pro): http://www.microsoft.com/express/Windows/
1. Download the Apache 2.2 Windows installer: http://httpd.apache.org/download.cgi
2. During the installation, select Custom setup type and make sure the Build Headers and Librariesoption is marked to be installed.
3. If your module’s source contains a .vcproj file, simply open it up. If not, just create a new project in Visual Studio.
4. In Visual Studio, go to Project -> Properties. Select Configuration Properties -> C/C++ -> General -> Addtional Include Directories. Add the include and lib folders from your Apache 2.2 installation folder (these folders will only exist if you installed the Build Headers and Libraries option earlier).
5. At this point, you should be able to at least compile your application. But if you try to build, which will produce the .so file, you will probably get errors like “error LNK2001: unresolved external symbol.” We need to set the Linker option to get rid of these errors.
6. Go to Project -> Properties -> Configuration Properties -> Linker -> Input -> Additional Dependencies. Enter full_path_to_Apache2.2_installation_folder\lib\*.lib (eg. D:\Apache2.2\lib\*.lib).
7. Now you can do a Release build and the .so module file should be created in your project’s release directory.
It’s actually pretty easy to do once you do it once, it was just a pain piecing together all the information to make it work and I’m just not familiar with Visual Studio.