Version 21 of Freewrap

Updated 2005-09-01 22:04:07

by Dennis LaBelle

homepage at http://freewrap.sourceforge.net/ The freewrap program turns TCL/TK scripts into single-file binary executable programs.

There are various forms of this application - from wrapping pure-tcl scripts to wrapping tk and I believe even tk + certain extensions. The pure Tcl version--freewrapTCLSH--generates an executable that's typically just over a quarter of a megabyte.


Alex [Vizantinos?] provides a recipe [L1 ] for reverse engineering a Freewrap-ped application. Dennis follows that up with a simple counter-recipe for use of a private encryption key.


Latest version (5.6) gives up source code encryption [L2 ].


MG notes on May 12th, 2005 that a v6.0 seems to be available, since the start of the year, according to the download's page. It uses Tcl 8.4.8.


See also tbcload and Freedelivery


In a world with Starpacks, mktclapp, and so on, what's the point of freeWrap? One benefit is that freeWrap builds in BLT.

MG I've been using Freewrap since before I knew Starkits existed (and possibly since before they did exist?). I've read a lot of very long pages on how to use a Starkit to make an executable of a Tcl script, which several files and utilities to download.. and then I just drag-and-drop my Tcl script onto Freewrap and my executable is made. That's why I've kept using it. Though, lately (I think since I downloaded freeWrap 6), I've found that if I edit the icons or version info of my freeWrap'd executable with Resource Hacker, as I've always done, it no longer works, which is a downside that would make me consider switching to Starkits now.'

EKB I had had the same experience, but now things have changed...

What was happening is that version 6.0 of Freewrap uses UPX to compress the executable. However, UPX doesn´t work when the executable calls itself, as Freewrap must (to use the zip vfs). So, only a core part of the Freewrap executable is UPX-compressed. As a result, if you run upx -d on Freewrap, it will run, but render it unusable.

The solution is simple: a non-UPX version of Freewrap. I just got an e-mail from Dennis LaBelle telling me that version 6.1 has been released with no UPX. Hooray! So, MG, you should be able to use FreeWrap again.

A/AK It's OK to use UPX when the executable calls itself. However, if the executable's tail is a zip archive (like in freewrap), the archive's table of contents must be adjusted when the preamable's size changes.

The standard InfoZIP's zip program can do it when the -A option is given. Thus, if someone has UPX-ed freewrap and wants to decompress it, or he has decompressed freewrap and wants an UPX-ed one, it's easy:

 upx freewrap.exe / upx -d freewrap.exe
 zip -A freewrap.exe

No more need to wait for the next version of freewrap. No more feature requests to Dennis LaBelle causing him to switch between using and not using UPX compression with each subsequent version.

EKB Thanks, A/AK. But this is deep waters for me... Am I right in thinking that the change will need to happen in the Freewrap makefile? Here are (I think) the relevant lines:

 $(PROG)$(EXE): $(PROG)_bare$(EXE) zipdir\freewrap.tcl zipdir\freewrapCmds.tcl zipdir\$(PROG).ico
          del $(PROG)$(EXE)

 ...

          echo /freewrap.tcl >zipdir\_freewrap_init.txt
        echo $(PROGREV) >>zipdir\_freewrap_init.txt
          copy /b $(PROG)_bare$(EXE)+$(TOP)\null.zip $(PROG).zip
        cd zipdir
          $(ZIP) -rA9 ..\$(PROG).zip *.*
          cd ..
        ren $(PROG).zip $(PROG)$(EXE)
          del freewish$(FW_EXT).exe
          copy $(PROG)$(EXE) freewish$(FW_EXT).exe
          freewish$(FW_EXT).exe ..\generic\setinfo.tcl freewrap$(FW_EXT).exe
          copy $(PROG)$(EXE) freewish$(FW_EXT).exe

 ...

 $(PROG)_bare$(EXE): $(OBJ) $(LIBSOPEN)
         link /OUT:$(PROG)_bare$(EXE) $(OBJ) $(LFLAGS) $(LIBS) $(OBJSTKTBL)
 #          $(TOP)\upx -9 $(PROG)_bare$(EXE)

(The last line was not commented out in version 6.0.)


Category Application