Bringing Visual C++ Toolkit to a Usable State

Microsoft offers its command-line C/C++ compiler for free. Unfortunately, as it ships, it's only useful for "Hello World" type of programs. Fortunately, many of the missing pieces can be found in other free packages distributed by Microsoft. When put together, they happen to be just enough to compile BFilter and its dependencies. Be prepared to download about 200 megs of data though. Let's start then.

  1. Download and install Visual C++ Toolkit 2003. From now on I am referring to C:\Program Files\Microsoft Visual C++ Toolkit 2003 (or wherever you have installed it to) as $VCTK.
  2. Download and install Microsoft Windows Platform SDK. Don't worry, you won't have to download all those 400 megs. The thing is named "Windows Server 2003 SP1 Platform SDK", but it works fine on Windows 2000 and above. Download PSDK-x86.exe, launch it and select custom install. Just two components are necessary:
    • Microsoft Windows Core SDK -> Build Environment -> Build Environment (x86 32-bit)
    • Microsoft Windows Core SDK -> Tools -> Tools (AMD 64-bit)
    The reason why we need the AMD64 tools is that they provide us with nmake.exe, lib.exe and cvtres.exe that happen to work fine on x86 machines. There are actually alternative ways to get those files, but the other component is still necessary. Now copy lib.exe, cvtres.exe and msvcr80.dll from C:\Program Files\Microsoft Platform SDK\Bin\win64\AMD64 to $VCTK\bin. The .dll is necessary because the executables depend on it. We don't copy nmake.exe because it's going to be in the PATH anyway after the next step.
  3. Open $VCTK\vcvars32.bat in Notepad and put the following to the bottom of it:
    Set PSDK=C:\Program Files\Microsoft Platform SDK
    Set PATH=%PATH%;%PSDK%/bin
    Set INCLUDE=%INCLUDE%;%PSDK%/include
    Set LIB=%LIB%;%PSDK%/lib
Now you have a working command-line build environment that can be accessed from Programs -> Microsoft Visual C++ Toolkit 2003 -> Visual C++ Toolkit 2003 Command Prompt.

Alternative Ways to Get Missing Pieces

  • nmake.exe can also be found in .NET SDK.
  • cvtres.exe can also be found in .NET Runtime or downloaded from here.
  • lib.exe can be replaced with a lib.bat that looks like this:
    link /lib %*