views:

698

answers:

2

Hello:

After running into major compatitiblity problems with C#, ASP.NET, MS Access, Linux, and Mono, I've decided to program in a language that is cross-platform, open source, and compatible with embedded databases that are also compatible with many platforms. I narrowed my choice down to TCL.

Before I began a sample application with TCL, I wanted to see how easy it was to create a stand alone application. I purchased a book entitled, "Practical Programming in TCL and TK", downloaded TCLkit, and FreeWrap, yet I am having troubles finding a methodological way to convert TCL in TK (Wish) into a standalone application.

Would anyone be able to provide simple steps towards converting a TCL TK script, such as a label with text on it, into an application, or a web resource that has a pretty straight forward explanation?

Thank you,

DFM

+12  A: 

To build a starpack you need a) a tclkit runtime, b) sdx.kit. You also need a "basekit", the executable that will be wrapped with your tcl code. For this example I'll assume you're creating an application for the same platform you are running on. You can create a basekit by simply copying tclkit (or tclkit.exe on windows) to another name, such as "basekit"

% ls
sdx.kit tclkit
% cp tclkit basekit
% ls
basekit sdx.kit tclkit

Now, create the code that you want to have wrapped into an executable. The convention is to create a directory with the name of your app and the suffix ".vfs" (for 'virtual file system'), then create a file named 'main.tcl' in that directory:

% mkdir myapp.vfs
% cat > myapp.vfs/main.tcl
package require Tk
label .l -text "Hello, world"
pack .l
^D
% ls myapp.vfs
main.tcl

Now to do the wrapping: for this you'll need the sdx.kit file. Assuming it and tclkit (or tclkit.exe) are in your current working directory, you wrap your app like this:

% ./tclkit sdx.kit wrap myapp -runtime basekit
1 updates applied
% ls 
basekit myapp myapp.vfs sdx.kit tclkit

The wrap command knows when you give it the argument "myapp" that it should wrap the contents of myapp.vfs, and that it should look for a file named "main.tcl" in that directory to be the program entry point. You can put whatever other files you want in that directory and they will all be wrapped, including platform-specific binary files, image files and anything else you want bundled up.

You now have an executable file, 'myapp', that is the wrapped application.

If you have the tclkits for different architectures you can use them (replacing 'basekit' on the command line with the kit for the target architecture) to cross-compile for other platforms.

For more information see How to create my first Starpack on the Tcl'ers Wiki

Bryan Oakley
Thank you Bryan - Your answer looks great. I should be able to get started now.DFM
DFM
Question about sdx.kit and tclkit - I cannot seem to get sdx and tclkit to qwrap. After spending a few hours trying to get sdx and tcl to qwrap, I kept getting the error invalid command name. I even followed the web instructions and changed the tclkit.exe to tclkitsh.exe. I think I am having a problem with the sdx file. How do you download the sdx file? All I can do is copy the text to notepad and change the extension to .kit. The sdx file doesn't download like a normal file, and I've tries multiple versions(?)ThanksDFM
DFM
Somehow copying the text of sdx.kit won't work -- it's a binary file. Maybe you're getting the source code? Download from this link: http://www.equi4.com/pub/sk/sdx.kit.
Bryan Oakley
Just tried and works perfectly on Windows too!
Remo.D
+1  A: 

kitgen build system may also help you at the beginning.

msorc