Mateusz Loskot :: hacking on, working out, living up

Visual C++ Toolkit 2003 still in use

22 Sep 2008 | mloskot

Charles Petzold’s TattooIn 2004, Microsoft published Visual C++ Toolkit 2003 - full version of Visual C++ 2003 optimizing compiler (version 1310) available free of charge. It was the first free, good and almost complete implementation of C++ programming language by Microsoft. It is quite old but still used by many developers.

The Toolkit is fairly complete, but you can not avoid a few hacks if you want to use it :-) So, I’ve decided to collect them all in one place to help building projects like GEOS, libLAS or GDAL/OGR with the Visual C++ Toolkit 2003.

Installation

First, installation of the following packages is required:

  1. Microsoft .NET Framework SDK 1.1
  2. Microsoft Platform SDK for Windows Server 2003 R2
  3. Microsoft Visual C++ Toolkit 2003 (no longer available from Microsoft website, just be persistent cuiling for it)

Hacks

This is list of hacks like installation of missing components and fixing a project makefiles:

  1. The .NET Framework SDK 1.1 installation (listed above) is required in order to get C Run-Time libraries installed: msvcrt.lib and msvcrtd.lib. The .NET SDK installer will copy these files (and a few other components) to directories located in:
C:\Program Files\Microsoft Visual Studio .NET 2003
  1. Surprisingly, import library for C++ Run-Time Library msvcp71.dll is not included in the Visual C++ Toolkit 2003 distribution. Missing files can be downloaded from CERN server: msvcprt.lib and msvcprt.def. Copy them into
C:\Program Files\Microsoft Visual C++ Toolkit 2003\lib 
  1. The Toolkit does not include lib.exe utility - Microsoft Library Manager. Fortunately, lib.exe is just a simple wrapper on Microsoft Incremental Linker - link.exe. So, in your NMAKE makefiles replace lib.exe (or lib) command with:
link.exe /lib

Alternatively, you can build custom lib.exe wrapper using lib.c program. Recently, I’ve fixed NMAKE makefiles of GEOS (r2190) and libLAS (r876) projects using the former option.

Environment

Most of articles about Visual C++ Toolkit 2003 and Platform SDK installation procedure suggest to permanently update environment variables like INCLUDE, LIB and PATH. Personally, I don’t like this approach. Instead, I write a simple SETMSVC71.BAT_ script which I execute in console window before I run NMAKE to build a software project using Visual C++ Toolkit 2003.

The script I use consists of three commands:

@echo off
CALL "C:\Program Files\Microsoft Platform SDK for Windows Server 2003 R2\SetEnv.Cmd"
CALL "C:\Program Files\Microsoft Visual C++ Toolkit 2003\vcvars32.bat"
CALL "C:\Program Files\Microsoft.NET\SDK\v1.1\Bin\sdkvars.bat"

Copy this script to location that is available from the PATH.

Sample build - libLAS

Below, a few simple steps are presented of using Visual C++ Toolkit 2003 and environment configured as presented above to build libLAS project. The same procedure should work for projects like GEOS or GDAL/OGR.

  1. Run Command Prompt (cmd.exe)
  2. Configure environment by executing SETMSVC71.BAT_ script:
C:\> SET_MSVC71.BAT

Check if basic commands are available: cl.exe, nmake.exe, link.exe.

  1. Go to libLAS source code directory:
C:\> cd dev\liblas\trunk
  1. Run NMAKE command to build libLAS library and utilities:
C:\dev\liblas\trunk> nmake /f makefile.vc

Good luck!

Fork me on GitHub