Much of the information here deserves to be consolidated with that found under the title, "How can I compile Tcl type scripts into binary code". One good non-Wiki reference on the topic is http://phaseit.net/claird/comp.lang.tcl/tcl_compilers.html .There are at least three main reasons someone begins asking about compiling Tcl scripts.
- I want to hide my Tcl scripts so that someone cannot steal (or at least modify) them.
- I want my Tcl scripts to run faster, so I want to compile them.
- I want to distribute my application as a single file which the user can put anywhere.
- Simply compiling the scripts into a stand alone intepreter (adding the scripts as a series of character strings into a simple mainline that then feeds them into the interpreter) won't hide them or even speed things up that much.
- The Tcl 8.x built in compilation phase into bytecodes does not provide hooks for storing or loading later the bytecodes. There is at least one other standalone compiler which addresses this issue.
- A variety of people have discussed encrypting the scripts and then building decryption into the pre-compilation code of the Tcl interpreter - but decryption is going to slow down your application (lriobf).
- There are applications such as freewrap which are available for turning certain kinds of applications into single executables. There are certain design considerations that I encourage people to discuss here or add links (things like applications that require one to source in code, or which mix tcl and other languages like shell, awk, perl, etc.). Some pointers include:
- Some work that has been done on the concept of a starkit allows one to build a 2 part install - a one piece interpreter with a number of extensions built in, and one file per application, which contains its own database. This addresses some of the concerns from users regarding multiple stand alone documents reproducing all of the window manager support multiple times, using up a LOT more disk space.
- Rewriting your application into a compilable language with an embedded Tcl code (perhaps making use of SWIG [1], or mktclapp [2], embedded C, etc.) is an alternative which is more work, but can obscure more of the code and provide some speed improvements if implemented properly.
Please provide other alternatives and discussions.
How to use Prowrap to create a stand alone application.
Building Stand Alone Executables in Unix with Mktclapp may be of use. Most of it also applies to users of Cygwin.
arjen David Zolli (kroc) presented an obfuscation tool (lriobf, [3]) at the 9th Tcl Users meeting in Strasbourg (2010).
