Building TCL/TK 8.6.4 with Visual Studio 2013
Downloads
For the impatient:
- TCL/TK 8.6.4, Release DLL Build, 32-Bit using Visual Studio 2013
- TCL/TK 8.6.4, Debug DLL Build, 32-Bit using Visual Studio 2013
- TCL/TK 8.6.4, Release DLL Build, 64-Bit using Visual Studio 2013
- TCL/TK 8.6.4, Debug DLL Build, 64-Bit using Visual Studio 2013
- TCL/TK 8.6.4 source patch for GetVersion
Prerequisites
- You need Visual Studio 2013.1. I cannot believe I am writing this down as a prerequisite on a page that has the title building TCL/TK 8.6.4 with Visual Studio 2013.1.
- You need the TCL/TK sourcecode. In the following, I am using Tcl 8.6.4 and Tk 8.6.4
- Unzip the sourcecode. At the end, you should have two directories, for example
c:\tk8.6.4
andc:\tcl8.6.4
.
The thing with GetVersion
If you try to build the plain vanilla sources in the build environment indicated above, you'll run into a problem: on Windows 8.1,
GetVersion
and GetVersionEx
are deprecated. If you do a short grep on the
And in the TK source, you'll find this:
c:\tk8.6.4\win>grep GetVersion *.c
nmakehlp.c:static const char *GetVersionFromFile(const char *filename, const char *match, int numdots);
nmakehlp.c: printf("%s\n", GetVersionFromFile(argv[2], argv[3], *(argv[1]+2) - '0'));
nmakehlp.c: * GetVersionFromFile --
nmakehlp.c:GetVersionFromFile(
tkWinColor.c: int version = LOBYTE(LOWORD(GetVersion()));
tkWinDialog.c: if (LOBYTE(LOWORD(GetVersion())) < 5) {
tkWinMenu.c: GetVersionEx(&os);
tkWinX.c: GetVersionEx(&os);
tkWinX.c: GetVersionEx(&os);
ttkWinXPTheme.c: GetVersionEx(&os);
Well, despair not: there is a nice article on codeproject.com
that gives you all the background information you'd ever want. In particular, it points out that using a pragma to disable the warning has the benefit that your code continues to run on earlier
versions of Windows, which, given widespread adoption or rather lack thereof of Windows 8.x is definitely the preferred option.
So, for example, in apps/apps.c
, I changed this:
if (LOBYTE(LOWORD(GetVersion())) < 5) {
simply to this:
#pragma warning (disable : 4996)
if (LOBYTE(LOWORD(GetVersion())) < 5) {
#pragma warning (default : 4996)
Notes:
- I wrote a script that changes the TCL/TK code for these patches, available for download.
So with these changes out of the way, let's get started.
Building the 32-bit version
- Open CMD.EXE in the directory
C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\bin
- Run
vcvars32.bat
- Change to the
win
subdirectory in the TCL source folder. For example, for me this isC:\tcl8.6.4\win
- Run
nmake -f makefile.vc
- Change to the
win
subdirectory in the TK source folder. For example, for me this isC:\tk8.6.4\win
- Run
set TCLDIR=..\..\tcl8.6.4
to ensure TK finds TCL. - Run
nmake -f makefile.vc
- Note: you can stop reading here if you only need the release build. The next few steps show you how to build the debug binaries as well.
- Change to the
win
subdirectory in the TCL source folder. For example, for me this isC:\tcl8.6.4\win
- Run
nmake -f makefile.vc OPTS=symbols
- Change to the
win
subdirectory in the TK source folder. For example, for me this isC:\tk8.6.4\win
- Run
nmake -f makefile.vc OPTS=symbols
Building the 64-bit version
- Open CMD.EXE in the directory
C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\bin\amd64
- Run
vcvars64.bat
- Change to the
win
subdirectory in the TCL source folder. For example, for me this isC:\tcl8.6.4\win
- Run
nmake -f makefile.vc MACHINE=AMD64
- Change to the
win
subdirectory in the TK source folder. For example, for me this isC:\tk8.6.4\win
- Run
set TCLDIR=..\..\tcl8.6.4
to ensure TK finds TCL. - Run
nmake -f makefile.vc MACHINE=AMD64
- Note: you can stop reading here if you only need the release build. The next few steps show you how to build the debug binaries as well.
- Change to the
win
subdirectory in the TCL source folder. For example, for me this isC:\tcl8.6.4\win
- Run
nmake -f makefile.vc MACHINE=AMD64 OPTS=symbols
- Change to the
win
subdirectory in the TK source folder. For example, for me this isC:\tk8.6.4\win
- Run
nmake -f makefile.vc MACHINE=AMD64 OPTS=symbols