twm's homepage logo
From someone who traveled abroad to learn appreciating his own country ...
generate standalone "executables" with Kylix
Deutsch English
Google
Search dummzeuch.de
Search WWW

The Problem

Programs written with Borland Kylix need a shared library (libborqt-6.9.so), which usually isn't installed on the target system. Because Linux does not automatically load shared libraries from the current directory the user must either explicitely install this library or set the environment variable LD_LIBRARY_PATH to include this directory.

The Simple Solution

The simple solution is a shell script like this:

                      
#!/bin/bash
QTLIBDIR=`dirname $0`
LD_LIBRARY_PATH="$QTLIBDIR:$LD_LIBRARY_PATH"
export LD_LIBRARY_PATH
$0.bin
                    

This script assumes that the shared libraries are located in the same directory as itself and the executable and that the executable has got a .bin extension (in Kylix set Project Options/Application/Output settings/Target file extension to "bin") e.g.:

                    
[twm@twmceleron kyrdesktop]$ ll
total 8100
-rwxr-xr-x    1 twm  twm    1 Jan  4 18:28 kyrdesktop*
-rwxr-xr-x    1 twm  twm  728 Jan  4 18:38 kyrdesktop.bin*
-rwxr-xr-x    1 twm  twm 7350 Jan  4 17:45 libborqt-6.9.0-qt2.3.so*
lrwxrwxrwx    1 twm  twm    1 Jan  4 17:45 libborqt-6.9-qt2.3.so -> libborqt-6.9.0-qt2.3.so*
                  

The script extracts the directory name from the parameter $0 and extends LD_LIBRARY_PATH to contain it. Then it starts the executable.

Drawbacks:

  • You have a copy of libborqt in every directory containing a Kylix program. That's unfortunate but harddisks have become cheap, so this is hardly a problem.
  • I (spoiled by Delphi and Windows) would prefer to have to copy only one executable to a new box and start it there. (Anybody remembers the annoying vbrun300.dll issue before Microsoft started including the Visual Basic runtime in Windows?)

Makeself to the Rescue

Makeself is a shell script which creates self extracting tar archives. It does so by prepending another shell script to the tar archive that automatically calls tar to extract the files and optionally calls another script embedded in the archive.

Using this tool you can easily create a self extracting tar archive which extracts all necessary files to a temporary directory and calls the startup script. After that the temporary directory will be deleted.

Example:

Lets assume the files listed above are located in a subdirectory called kyrdesktop and makeself.sh is in the search path. We want to create a self extracting tar archive that can be klicked e.g. in KDE to start the application it contains.

To do this, call makeself like this:

                  
makeself.sh --nox11 --nowait kyrdesktop kyrdesktop.run "description goes here" ./kyrdesktop
                

The parameters mean the following:

--nox11
do not open an xterm window while extracting files
--nowait
do not wait for user input after the program terminated
kyrdesktop
name of the subdirectory to be compressed
kyrdesktop.run
name of the archive file to create
"description ..."
a description of the archive's content
./kyrdesktop
the script to call after extraction (please note the dot!)

This command creates a new file kyrdesktop.run and makes it executable. At the beginning of this file you will find a shell script which calls tar to extract the archive to a temporary directory. It then changes to this directory and calls ./kyrdesktop. It waits for the script to return (meaning that the program terminated) and deletes the temporary directory.

You can copy the file kyrdesktop.run to a different computer and execute it there. If you did everything correctly, no additional files are necessary.

The Commercial Solution

If you need someone to blame if it doesn't work ;-) or more flexibility than the solution presented here check out InstallMade. I don't know whether it is any good but it seems to be the only installer for Kylix programs available.

(c) Copyright 2004 by Thomas Mueller, alle Rechte vorbehalten



This document was generated using AFT v5.096

last updated: 2012-10-14 twm
Post to del.icio.us Best Viewed With Open EyesValid XHTML 1.0!