The Fnordistan Department of Software Engineering

How to Package a VisualWorks Application, Part II

If you followed the instructions in Part 1, you now have a runtime image for your application. Now I will finish this tutorial with instruction on how to compress your image and then package it as a stand-alone executable. To do this, we will need two external tools.

Part 2:

Deploying the Runtime Image

Compress the Runtime Image

Even after stripping your runtime image down, it is likely still over 10MB in size. We can compress it with a tool that comes with VisualWorks called imageCompress.exe. It should be located in "$VW_HOME\betas\packaging". It is used on the command line and takes two arguments: the image you wish to compress, followed by the name you choose for the compressed image.

I copied it to my development folder, and use it like so:

C:\Documents and Settings\Fnordistan\My Documents\Smalltalk>imageCompress.exe runtime.im compressed-runtime.im
uncompressed size 12622332, compressed size 4732883, compressed to 37.50%
normal and compressed files compared ok

As you can see, it compressed a 12.6MB runtime image to a 4.7MB image.

The compressed image (compressed-runtime.im, which you can rename if you like) theoretically may run slower than the uncompressed image, but I have not noticed a discernible difference in my compressed runtimes.

Make a Windows Executable

Now you have a compressed runtime image, but it still will only work on a machine that already has VisualWorks installed (just as Java applications will only run on machines with a Java runtime installed). (It should be noted that this runtime is worth holding onto and distributing, since it will run on any platform with VisualWorks installed, whether Windows, Linux, or Mac OSX.)

Now we're going to turn it into a stand-alone executable that can be distributed to anyone with a Windows machine. To do this, we are going to use Resource Hacker, a free tool which can be downloaded at the preceding link, but which should also be found in $VW_HOME\betas\packaging.

Resource Hacker is useful for lots of things and has a GUI interface, but we are just going to use it on the command line to create an executable:

C:\Documents and Settings\Fnordistan\My Documents\Smalltalk>"C:\Program Files\ResourceHacker\ResHacker.exe" -addoverwrite "C:\Program Files\VisualWorks\bin\win\visual.exe", SmallRoller.exe, compressed-runtime.im,332,332,

From the above, you can see that I specified the full path to ResHacker.exe, followed by the full path to my VisualWorks executable (yes, you could use environment variables here, but I'm printing out everything explicitly), followed by the name of the executable I want to end up with (SmallRoller.exe), followed by the resource (in this case, the compressed runtime image), followed by a resource mask. The exact parameters are specified in ResHacker's help files. Note the commas; ResHacker is very picky about command line arguments!

If you did everything right, you now have an executable called SmallRoller.exe which will work on any Win32 system, regardless of whether it has VisualWorks installed. ResHacker has basically packaged a minimal VisualWorks runtime along with the compressed image. This makes it somewhat larger than the image alone, but makes it portable.

For a finishing touch, you can use ResHacker to add an icon to your application to replace the default VisualWorks icon -- see ResHacker's help files.

I hope this tutotial has proven useful to someone!