For those of us who write their own Tcl code, scripts are probably fine but for almost everyone else executables are needed.
Freewrap is probably the easiest to use utility ever produced to generate executables from Tcl scripts. There are other alternatives around, such as Starkits, but when all gnocl sharables are in their own place and available for other apps or scripts, what more could be desired? So, how are the executables made? Firstly, obtain a copy of Freewrap from Sourceforge. Both pre-compiled binaries and source tarballs are available so take your choice. Next, copy the executable into some location in the system path such as /usr/local/bin and then you're ready to create some standalone apps.
In order to use Gnocl it's necessary to load binary packages in the right way. Its no longer possible to simply use the familiar ‘package require’ instruction, the alternative load command needs to be used. One way to load these libraries would be to include a unique copy with the application executable, indeed application specific modules can be accessed in this way. The Gnocl libraries are intended to be shared and so these ought to be accessed from their appropriate installations. To do this with the load command the full path and file name needs to be provided. For local copies this would be:
Whereas in order to access a system wide installation of the Gnocl libraries this might be something like:
With this in mind then, an absolute minimal script looks something like this:
This can then be turned into an executable using the command:
From this an executable named ‘hello’ would be generated.
But, what about your potential users? What if they don't know anything about Gnocl or, most likely, do not want to go through the whole process of downloading tarballs, dependencies and building apps from sourcecode? Relax, this is not a problem. Freewrap can allow the wrapping of both script and binary packages into itself. The bottom line is then, there's no need even to install Gnocl or any other module for that matter. Yay! I hear you cry. How is this done?
The FreewrapTCLSH command can take a number of parameters which instruct it on how to proceed. A simple list of files will tell it what to included in a wrapped script. Returning to the familiar hello.tcl script, the gnocl.so shared library can be wrapped together with the script using like this:
Previously the separate gnocl.so module was accessed using the load command. Wrapped packages cannot be read directly and so need to be installed and then loaded. The ::freewrap::unpack command does it for you. Here's how the hello.tcl script is modified:
Here the gnocl.so file is unpacked (the default directory is /usr/tmp) and the path returned to the calling script. This can then be loaded as usual before any clearing up of temp files takes place. This cluster of commands is ripe for modification into a more general purpose procedure which typically would look something like this:
Although the process of adding new packages is simple in principle, no-one wants to type lengthy options each time a fresh wrap is needed. The following shell script shows how it's possible to draw in the 'core' Gnocl package set and bring them together into a single wrapped application. Here, fresh copies of shared objects are assembled during each wrap session, useful if the packages too are still in development.
Tutorial Pages >