I'm trying to make a starpack like single binary which wrapped a bunch of tcl scripts inside. I looked at the TclApp doc from ActiveTcl, it seems like you have to use their basekit (e.g. /usr/local/ActiveTcl/bin/base-tk8.5-thread-linux-ix86). However, I have built the interpreter into my own binary. How to make my binary a basekit?
1 Answers
I'd start by asking whether it is really necessary to have your own build of Tcl. If you can structure your code so your custom pieces are loadable extensions (linked correctly against the stub library) then you can just use it with a standard kit distribution.
But if your code is such that it really needs to be built as the main executable, you can do what you're after. You probably want to start from Kitgen, which is both maintained and reasonably open. You'll have to do some work to make things assemble correctly; in particular, make sure your code is built with static linking against any external libraries it needs (with the exception of the C library and other things that can reasonably be assumed to be present on the target platform) as the runtime link environment of a kit-based distribution of Tcl is distinctly weird. Building as a stubbed extension (which you can just store inside the kit package) is much simpler to get right.

- 133,037
- 18
- 149
- 215
-
Thanks for your answer! Can you clarify a bit about what is 'building as a stubbed extension'? Also, if I want to just wrap up all my tcl file/code into a single file (kit package?) and load it using my binary, what change do I need to make for my binary (which include the interpreter stuff). – Terry Shi Jul 25 '12 at 18:06
-
@CyberSnoopy: The [official documentation](http://www.tcl.tk/man/tcl8.6/TclLib/InitStubs.htm) says most of what you need. For the rest, [the wiki page](http://wiki.tcl.tk/285) on the topic is the place to start (of course). Plus you can search here; I believe there are questions on SO that have answers that cover the basics. – Donal Fellows Jul 25 '12 at 19:16