poSoft Text Logo
Overview
poApps
Tcl extensions
SGI related
Currently selected Unsupported
Tcl and VC2005
mktclapp patch
photo patch
glob patch
History
Related links
Contact
poSoft Logo
Valid XHTML 1.0 Transitional

Compiling Tcl with VC2005

Intention:

June 2006: A question on c.l.t. about problems compiling Tcl with Visual Studio 2005 initiated this little project.
As I have access to VC2005 at work (because my next project deals with .NET and C#) I took the chance to test VC2005 on a C project.

Results:

  • I was able to compile static and dynamic versions of tclsh and wish for versions 8.4.12 and 8.4.13.
  • The tcltest suite of Tcl 8.4.13 compiled with VC2005 gave the same results as the version compiled with VC6, with the exception of 10 tests related to env.test (env-2.1 till env-4.5):

    VC6: all.tcl: Total 10859 Passed 10079 Skipped 759 Failed 21
    VC2005: all.tcl: Total 10859 Passed 10069 Skipped 759 Failed 31

  • 3 source files had to be changed in the Tcl sources, none for Tk:
    • generic/tcl.h
      Line 387: Add inclusion of stat.h for definition of _stati64:
      #      else /* __BORLANDC__ */
      #include <sys/stat.h>
      typedef struct _stati64	Tcl_StatBuf;
      
    • generic/regerror.c
      Lines 53 ff (Function regerror): Changed name of first parameter from errcode to errorcode, because of a compile error message in VC2005.
      This reminds me on a bug in VC6, where you were not allowed to have near and far named variables.
    • generic/tclExecute.c
      Line 398: The strangest error (or bug) encountered. If using floor in the table below, a compile error is issued, so I replaced it with the following static function.
      
      static double myFloor (double in) {
          return floor (in);
      }
      
      
      BuiltinFunc tclBuiltinFuncTable[] = {
      ...
      {"floor", 1, {TCL_DOUBLE}, ExprUnaryFunc, (ClientData) myFloor},
      
  • In the first attempt the dynamic version didn't work. I always got the following runtime error:
    R6034 An application has made an attempt to load the C runtime library incorrectly.

    This was due to the new deployment strategy of Microsoft. You either have to redistribute the manifest file of each DLL or EXE, or include it in your binary with the Manifest Tool mt.exe. After making changes in the makefile.vc and rules.vc files of both Tcl and Tk, the dynamic versions also worked.

  • See the modified files in the download section for further details. All changed parts are marked with OPA.

  • I have used the existence of environment variable FRAMEWORKSDKDIR to check the usage of VC2005. Don't know, if this is the correct/best way.

Top of page

Downloads:

File name Description
tcl8.4.12.zip Changed source files for Tcl 8.4.12
tcl8.4.13.zip Changed source files for Tcl 8.4.13
Top of page