Version 8 of Building Tcl with the free VC++ toolkit

Updated 2004-05-25 06:17:18 by mjk

PT 13-May-2004

Microsoft recently made the optimising version of their C and C++ compiler available for free download [L1 ]. This is fairly useful for building open source projects which often provide a Visual C++ build environment. Tcl is one such OS project.

There are a few issues using the toolkit to build anything useful. There are a few utilities that have not been provided and at least one link library. However, all is not lost. You can get all the bits from alternative free sources.

Firstly, you should install the most recent Platform SDK [L2 ] - this provides all the current libraries and headers for building anything on windows.

Missing utilities: cvtres.exe, lib.exe and nmake.exe. It turns out that you can use the versions provided with the Platform SDK Win64 tools. I suggest copying these utilities from %MSSDK%\bin\win64\ to your VC++ toolkit binaries directory.

Missing msvcrt.lib - this is the link library for the C runtime used by Tcl and most extensions. You can in theory create a link library from a .dll using link -dump -exports dllname and some processing, but I have been unable to make this work. Instead you can install the .NET Framework SDK (free download) and get a copy of msvcrt.lib from this [L3 ]

Finally, the compiler no longer accepts the -GD option and the linker will not accept -link50compat so you should remove these.

Setup your INCLUDE, LIB and PATH environment variables to point first to the Platform SDK and then the toolkit directories: eg: my vcsetup7.bat file...

  @echo off
  set MSDEVDIR=%VCToolkitInstallDir%
  set INCLUDE=%MSSDK%\include;%VCToolkitInstallDir%\include
  set LIB=%MSSDK%\lib;%VCToolkitInstallDir%\lib
  set PATH=%MSSDK%\bin;%VCToolkitInstallDir%\bin;%PATH%

Now you can build tcl using the <tcl>/win/makefile.vc NMAKE makefile. Or you could use Msys and CC=cl configure


jcw - Would it be an idea to start using tclsh to streamline this sort of thing? I know that using tcl to build tcl sounds silly, but since we have several perfectly well-working binaries for Tcl on Windows, I think we can by now rely on it. The bootstrap issue is long behind us for Windows. So as addition to the above, it would now be quite feasible to create a Tcl script which does all of the above (even fetches things not yet present, if you really want to push it). This would make it possible to say to anyone:

  To build the latest Tcl/Tk on Windows, get one script and tclkitsh or some such, and do <x>.  Done.

The script could be as straightforward or clever as we care to make it.

I've used Tcl to drive the "genkit" build system, and have to admit that it really simplifies things, without having to make sure people have wget, a specific shell, etc. On Windows, it would be even more useful, to avoid getting a specific version of msys, or cygwin, and what have you not. In fact, it'd simply be a smaller download.

So I guess the question is really a more general one: could this be a good time to start using Tcl for our own tasks some more?

CL reacts: yes. It strikes me as a pure win. In particular, even if I'm stranded on, let's say, an embedded system which somehow lacks the Tcl I need to bootstrap, I assume I can move to some other host, and ask it (this contemplated Tcl-based generation system *will* have powerful introspection, no?) what I need to do on another system. This improves my life in every dimension when compared to reliance on *make.

mjk: It would be a brilliant idea to use Tcl as a replacement for configure scripts and makefiles. I've been lately struggling with various makefiles, which have been made for Visual C nmake utility and I have been converting makefiles for MinGW and Borland Make by hand (these were not related to Tcl/Tk in any way). This Tcl build-script idea would solve all dependencies on various compiler/system-specific tools if made right.