Updated 2014-06-02 20:27:28 by dkf

[I was excited to find this page then disappointed when I read it. Does anyone have a "simple" example of a "complex" Starkit?]

[Apparently this page will be filled in later... Was it meant to contain material from some paper on Starkits?]

[Several complex pure Tcl Starkits can be found in the sdarchive [1], but which would constitute good examples?]

The following was added to this page 2006-11-07, but looks more like a critcl example.
 package require critcl
 critcl::cproc abc {} Tcl_Obj* {
    char test[4] = "abc";
    Tcl_Obj * rv = Tcl_NewStringObj ("abc", 3);
    Tcl_IncrRefCount (rv);
    return rv;
 critcl::cproc 123 {} Tcl_Obj* {
    char test[3] = {1, 2, 3};
    Tcl_Obj * obj = Tcl_NewByteArrayObj (test, 3);
    Tcl_IncrRefCount (obj);
    return obj;
 puts [abc]
 binary scan [123] H* result
 puts $result

MG has recently started looking at Starkits and Starpacks for the first time, for deployment of an app he's working on using Tcl 8.5 that he plans to deploy on Windows, Linux and MacOS X (hopefully). It has (currently) about 5 separate Tcl files, and also 2 binary extensions on Windows only. And it couldn't have been easier to set up (somewhat to my suprise, if I'm completely honest).

Using the instructions to help you Build Your First Starkit, I wrapped the main file of my program into a Starkit, then unwrapped it again (so I had a "myapp.vfs" directory). At this point, the Starkit just sourced the other Tcl files from the same folder.

Then I moved all my extra Tcl files into myapp.vfs/lib/app-myapp, and edited the pkgIndex.tcl file in that folder (which contained the single line)
  package ifneeded app-myapp 1.0 [list source [file join $dir myapp.tcl]]

to add
  package ifneeded app-myapp-file1 1.0 [list source [file join $dir myapp-file1.tcl]]
  package ifneeded app-myapp-file2 1.0 [list source [file join $dir myapp-file2.tcl]]
  # etc

Each of the extra files for my app then got
  package provide app-myapp-file<num>.tcl

added to the bottom of them, and in my main file (now myapp.vfs/lib/app-myapp/myapp.tcl), I changed
  source myapp-file1.tcl

  package require app-myapp-file1 [package versions app-myapp]

And that was it. I re-wrapped it into a Starkit (and later, using the example on How to create my first Starpack, a starpack (.exe) for Windows), and it ran perfectly. (For me, including binary extensions was just a case of copying the .dlls into myapp.vfs/lib/app-myapp/ and adding package ifneeded statements for them into the pkgIndex.tcl file; there are more complications if you need to deploy compiled extensions on more than one platform, but that's for another page and, thankfully, not something I needed.)

Hopefully that rambling will help someone else planning to do the same thing. If I ever get the app finished, I'll try and remember to post a link here, in case anyone wants to take a look in the star[kit/pack].

I have a program that gets most of its code from a lib directory bundled with the application. The application's lib directory includes packages in subdirectories and tcl files automatically sourced via tclIndex. I followed the basic Starpack instructions How to create my first Starpack and then just copied everything in my original lib directory into the .vfs lib directory and it worked with no other code changes. It looks like the starkit sets up the auto_path global to include the startkit's lib directory for you, so if you already have other packages and libraries set up properly, including in a starpack turns out to be just a simple copy command.

Just to be clear on the file structure, here's a sample of how the original application would be organized. The executable program is myApp.tcl. myApp.tcl has a line in it to set up auto_path with the myApp/lib directory (I don't think setting auto_path is needed anymore when run in a starpack). I just copied everything in myApp/lib into myApp.vfs/lib.

  • myApp/
    • myApp.tcl
    • lib/
      • tclIndex
      • file1.tcl
      • file2.tcl
      • package-a/
        • (package-a files)

The result in the unwrapped starpack:

  • myApp.vfs/
    • main.tcl
    • lib/
      • tclIndex
      • file1.tcl
      • file2.tcl
      • package-a/
        • (package-a files)
      • app-myApp/
        • myApp.tcl
        • pkgIndex.tcl