Purpose: gather together tips and techniques, tool recommendations, etc. for compiling Tcl and related extensions on a Windows machine. See also the [C] page. ---- [Steve Blinkhorn] wrote on comp.lang.tcl recently [http://groups.google.com/groups?threadm=acvls9$hj8$1%40fastnet.prd.co.uk] praising the Mingw C compiler ([mingwin]) distribution as being the way one can compile the same code on windows as well as various unix systems. [[Re: cross-platform compiles - Is there a version of mingw for MacOS? ''For Mac OS <=9, no there isn't (at least not that I know of), but for Mac OS X, of course there is 'gcc' as standard.'']] ---- Those who have the financial wherewithal to buy Visual C++ have been advocating its use, as the executables are ''better''. But wait--does use of Microsoft's C compiler require money? "[Microsoft C compiler and Tcl]" ---- Many times Window developers attempt to compile Tcl and Tk using the Cygnus [Cygwin] Windows development environment, since that's what they use for other projects. For reasons that at least one non-Windows developer does not understand, Tcl doesn't compile with the default Cygnus environment. Thus, people keep telling people to use the Mingw C compiler mentioned above. [GPS] Tcl/Tk 8.4.1 and the CVS HEAD as of Jan/27/2003 compile with Cygwin for me. I've found that I can do a MinGW (using Cygwin's MinGW package) build while in Cygwin's XFree86 if after I run ./configure I edit the Makefile and add -mno-cygwin after gcc. I've even built some simple extensions using it. ---- Another popular free C compiler is the Borland C compiler. See [Helmut Giese]'s comp.lang.tcl article titled '''Borland support: Wrapping it all up''' from Mon, 29 Jul 2002 19:29:28 GMT [http://groups.google.com/groups?threadm=3d459689.2875662%40News.CIS.DFN.DE], in which Helmut volunteers info on using Borland compiler to build Tcl. In summer 2003, Helmut is working to make 8.5 generate correctly for Borland "out of the box". Also of potential interest are the LCC-Win32 [http://www.cs.virginia.edu/~lcc-win32/] and LCC [http://www.cs.princeton.edu/software/lcc/] compilers. ---- Another commonly discussed technique is using a Linux machine and cross compiling to generate Windows binaries. [[Someone have some URLs or wiki references here?]] See [cross-compiling] for a cook book for that. I have seen notes indicating that Tcl and Tk can be compiled using the gcc free compiler in unix as well as Win32 (EGCS, [FSF], cygwin32, [mingw32]) [[There's duplication between this text and that in "[C Language]".]] environments. Also, Win32's lcc should work. See http://www.xraylith.wisc.edu/%7Ekhan/software/gnu-win32/ , http://www.xraylith.wisc.edu/%7Ekhan/software/tcl/ , http://www.cygnus.com/misc/gnu-win32/ , http://sourceware.cygnus.com/cygwin/ , http://www.cs.virginia.edu/%7Elcc-win32 , ftp://ftp.franken.de/pub/win32/develop/gnuwin32/mingw32/porters/Mikey/ , ftp://ftp.freesoftware.com/pub/sourceware/cygwin/latest/setup.exe , ftp://ftp.yggdrasil.com/mirrors/site/sourceware.cygnus.com/pub/cygwin/latest/ , ftp://ftp.freesoftware.com/pub/sourceware/cygwin/latest/ , http://www.hwaci.com/sw/mktclapp/win32-compile.html Be sure that you understand http://sources.redhat.com/cygwin/faq/faq_9.html#SEC145 very well, perhaps even discussing it with a lawyer, before using cygwin to produce software you wish to sell. Nothing there prevents you from doing this - however, there are a variety of considerations that one needs to make, when using tools some of which are covered by the GPL. ---- "Packers ..." [http://linux20368.dn.net/protools/packers.htm] describes a variety of products of interest to those involved in application-level [obfuscation], compression, and so on. ---- To build Tcl using VC++ open a command prompt in the win directory of the source and type the following two commands: First call vcvars32.bat to setup the environment. This is located in vc\bin of VC++ 5.0 or vc98\bin for VC++ 6.0. Microsoft Windows 2000 [Version 5.00.2195] (C) Copyright 1985-2000 Microsoft Corp. D:\tcl_workspace\tcl_head_stock\win>c:\dev\devstudio60\vc98\bin\vcvars32.bat Setting environment for using Microsoft Visual C++ tools. D:\tcl_workspace\tcl_head_stock\win> Next, invoke the makefile, called makefile.vc: D:\tcl_workspace\tcl_head_stock\win>nmake -f makefile.vc Microsoft (R) Program Maintenance Utility Version 6.00.8168.0 Copyright (C) Microsoft Corp 1988-1998. All rights reserved. =============================================================================== *** Compiler has 'Optimizations' *** Compiler has 'Pentium 0x0f fix' *** Linker has 'Win98 alignment problem' *** Intermediate directory will be '.\Release\tcl_Dynamic' *** Output directory will be '.\Release' *** Suffix for binaries will be '' *** Optional defines are '' *** Dependency rules are not being used. cl -nologo -c -W3 -YX -Fp.\Release\tcl_Dynamic\ -QI0f -O2 -Op -Gs -MD -I "..\win" -I"..\generic" -Fo.\Release\tcl_Dynamic\tclAppInit.obj ..\win\tclAppIn it.c tclAppInit.c rc -fo .\Release\tcl_Dynamic\tclsh.res -r -i "..\generic" -D__WIN32__ . .\win\tclsh.rc cl -O2 -Op -Gs -nologo -c -W3 -YX -Fp.\Release\tcl_Dynamic\ -QI0f -Zl -D STATIC_BUILD -I"..\win" -I"..\generic" -Fo.\Release\tcl_Dynamic\tclStubLib.obj . .\generic\tclStubLib.c tclStubLib.c ...etc... Numerous targets and options exist. Read the top of makefile.vc itself for all the details. -- [DG] See also [TEA]. ---- Are there environments similar to [Cygwin] for Windows that allow one to compile Unix applications on Windows? For instance, I've heard references to [David Korn]'s UWin . [LV] Besides UWin, there is Interix, aka SFU aka SUA I think now. This is a package that Microsoft makes available for free download now, and which they are incorporating into future releases. I suspect there are more. [TV] Cygwin IS capable of compiling serious unix applications to windows, and it is freely downloadable and since some time now comes with a easy to use installer app. Also, you can select to automatically install XFree86, ax xserver for direct and parallel use under windows, which can even accomodate KDE on windows, which worked, but I must fix mine after a cygwin upgrade. The xserver works networked, too, for instance if you want to access a linux machine on windows, you can adjust you DISPLAY variable to have windows on the other machine cross the net, which is good to develop multiple platform. I did do a tcl/tk build under cygwin some time ago, I guess 8.0 or so, which I could complete with some minor warnings/errors (closing stdout or something stupid) with some work, though. If anyone did recently with success before I might throw in some time, I'd like to know. ---- The define of STATIC_BUILD is important when compiling with Visual C 6, as tcl.h does import and export macros differently based on the symbol. If you get unresolved references to _imp_SomeSymbol, this may be something worth pursuing for a resolution. -- {unknown author} But STATIC_BUILD is set correctly by makefile.vc and the TEA build system already. The only point of contension is when one links to tcl84s.lib that -DSTATIC_BUILD should have been used on the sources when compiled for projects using Tcl. How Tcl builds itself is already managed by the makefiles. If in fact, one is compiling Tcl using an alternate method, yes, they had better set all the macros correctly and for that I agree. -- [DG] ---- Related material appears under such titles as "[Building Tcl DLL's for Windows]", "[How to create mingw32 libraries from DLLs]", and "[Building Extensions on Windows]". ---- [Category Porting] - [Category Windows]