From: Schelte B. <tc...@tc...> - 2024-09-20 20:31:07
|
Thanks Brian, I stupidly went by the instructions given in the TIP. But clearly they are missing some crucial steps. First of all, Tcl has to be configured with --disable-shared and --without-system-libtommath (because some (most?) target systems will not have libtommath installed). Then, after entering the myvfs.vfs directory, you have to install a copy of tcl_library in there. This can quite easily be done by unzipping ../tclsh. Finally, it's best to use the zipfs mkimg command from Tcl to create the binary. If you just append the zipped myvfs.vfs to the end of a copy of tclsh, you end up with 2 copies of tcl_library in the binary, because there will then essentially be 2 zip files appended. The zipfs mkimg command should not produce any output. If it does, there is probably something wrong with the specified arguments. It may also be advisable to build tclsh on an old(ish) OS. This will still run on a newer OS. The reverse is probably not true. At least I got an error: /lib64/libm.so.6: version `GLIBC_2.38' not found With those changes, I finally managed to create a single file executable. Next step: Include Tk. Schelte. On 20/09/2024 14:34, Brian Griffin wrote: > The mkimg command is not a complete operation. It does only two things: 1) remove any existing zip archive from the original image when copying it to the destination image, and 2) append the new zip archive to the new destination image. > So, it’s only one small improvement from using cat. > > It is still up to the programmer to create a full library from the original before using mkimg. > > From my perspective, it only makes sense to use static tclsh or wish images to create custom applications. Using dynamic shared libraries is possible, but complicates construction and installation significantly. > > -Brian > (from mobile device) > >> On Sep 20, 2024, at 06:29, Schelte Bron <tc...@tc...> wrote: >> >> All, >> >> As I was interested in the new "Task Executables" functionality provided by TIP 430 (basically an alternative for starpacks), I did some experiments and got unexpected results. >> >> I used this main.tcl: >> puts "Script: [info script]" >> puts "Library: $tcl_library" >> puts "Mounted: [dict keys [zipfs mount]]" >> >> After compiling tclsh, I performed the following commands: >> cp tclsh demo >> zip demo.zip main.tcl >> cat demo.zip >> demo >> ./demo >> >> First of all, I found a difference between building with and without --disable-shared. >> Shared: >> Script: //zipfs:/app/main.tcl >> Library: //zipfs:/lib/tcl/tcl_library >> Mounts: //zipfs:/lib/tcl //zipfs:/app >> >> Static: >> Script: //zipfs:/app/main.tcl >> Library: /home/sbron/tcl/tcl/library >> Mounts: //zipfs:/app >> >> I was surprised to find that with the static build, tcl_library points to the library in the source tree. So then I tried moving the demo binary to another location. That resulted in: >> application-specific initialization failed: Cannot find a usable init.tcl in the following directories: >> {} /home/sbron/usr/lib/tcl9.0 /lib/tcl9.0 /lib/tcl9.0 /library /library /tcl9.0/library /tcl9.0b4/library /tcl9.0b4/library >> >> >> >> This probably means that Tcl wasn't installed properly. >> >> Script: //zipfs:/app/main.tcl >> Library: /tcl9.0b4/library >> Mounts: //zipfs:/app >> >> Running the static tclsh interactively, I get a different result: >> % source main.tcl >> Script: main.tcl >> Library: //zipfs:/app/tcl_library >> Mounts: //zipfs:/app >> >> I can move the tclsh binary to another location without any issues. >> >> As a final attempt, I moved main.tcl into a directory demo.vfs and then ran the following command from the tclsh: >> >> % zipfs mkimg demo ./demo.vfs ./tclsh >> ./demo.vfs/main.tcl >> >> This produced a binary that was smaller than the tclsh binary. Running it just gave me a command prompt. Manually sourcing the script then produced the following: >> % source demo.vfs/main.tcl >> Script: demo.vfs/main.tcl >> Library: /home/sbron/tcl/tcl/library >> Mounts: >> >> Is there something I'm doing wrong? Or is the TIP 430 implementation incomplete? >> >> >> Schelte. >> >> >> _______________________________________________ >> Tcl-Core mailing list >> Tcl...@li... >> https://lists.sourceforge.net/lists/listinfo/tcl-core >> |