How to compile FastCGI library in Visual Studio 2010 C++

FastCGI comes with Win32 project for VisualStudio6. Unfortunately when you try to open it in VisualStudio2010 the project will be corrupted. To correctly compile it for VS2010 it’s necessary to download library sources, get patches from cybozu.co.jp site and apply it.

Download library

Download latest version of Development Kit here and extract it to standalone directory.

FastCGI

Get and update patches

Download all five patches from Cybozu site. Now when you have patches it’s necessary to convert all files to correct windows-ending format. This can be done for example in Notepad++.

Convert to windows EOL

Get patch.exe application

Now you need some application capable to apply the patches. Unfortunately windows doesn’t contain any application for this task and also lot of comparing/merging applications can’t do that.

The simplest way is to download windows conversion of linux patch.exe app. Get it from gnuwin32 site – patch for windows.

Apply patch to project files

Apply patches

Open directory with fastcgi library, copy all patch files to this directory and open command line. As next run patch command for all fives patches:

...\fcgi-2.4.1-SNAP-0311112127>patch -Np1 < 4-vc9.patch
patching file Win32/FastCGI.sln
patching file Win32/authorizer.vcproj
patching file Win32/cgifcgi.vcproj
patching file Win32/config_h.vcproj
patching file Win32/echo-cpp.vcproj
patching file Win32/echo.vcproj
patching file Win32/echox.vcproj
patching file Win32/libfcgi.vcproj
patching file Win32/logdump.vcproj
patching file Win32/size.vcproj
patching file Win32/threaded.vcproj

In case you will see following error message:

patching file Win32/FastCGI.sln
Assertion failed: hunk, file ../patch-2.5.9-src/patch.c, line 354

This application has requested the Runtime to terminate it in an unusual way.
Please contact the application's support team for more information.

it’s necessary to convert ALL patch files to correct Windows format (correct EOL) as mentioned in previous section.

More patches…

When you apply patches by cybozu it’s time to apply my own patches ;-).

Manually updated rejected file

As first, it’s probably that you will see following message:

1 out of 26 hunks FAILED -- saving rejects to file libfcgi/os_win32.c.rej

It’s because original patch is for older version of library and file os_win32.c  is slightly different. To fix that, edit this file at line 841 and manually update following line:

//original
int len = p - bindPath + 1;

//updated line
intptr_t len = p - bindPath + 1;

Update VS project file

Now turn off generating the Map Files in project configuration. These files aren’t necessary and it isn’t possible to compile project correctly with this settings.

Turn off .map files

DONE

And that’s all. Now you will be able to sucesfully compile fast-cgi library.

Compilation complete

External links

3 comments

  1. Thanks, this was perfect!

    I had some trouble with the build, which I tracked down to the fact that one of the folders in the file path included a space. Once I removed the space, it built fine.

    Also, I had trouble getting the GnuWin32 patch.exe to work; it was opening a blank prompt window instead of applying the patches. I ended up applying them on a UNIX system.

  2. Thanks for the info! The note about disabling the map file generator was really helpful. I also found that I didn’t need to convert the line endings.

Leave a Reply

Your email address will not be published. Required fields are marked *