| Kylix Deployment Notes for "Hello World" | ||
| or, just how hard can it be to deploy a simple CLX application in Linux? | ||
Consider a simple Delphi/Kylix "Hello World" application with a single "ShowMe" button with the following click handler:
| procedure
TFormHelloWorld.ButtonShowMeClick(Sender: TObject); begin ShowMessage('Hello World') end; |
I was surprised that without reading manuals and online help, I could not figure out how to deploy such a simple standalone CLX application in either Windows or Linux.
Deployment of Delphi VCL "Hello World" Windows Application is Quite Simple
This simple "Hello World" VCL application can be compiled in Delphi 1 through Delphi 7. The resulting HelloWorld.EXE standalone executable can be deployed to Windows 95, 98, 2000 or XP machines by simply copying the EXE file. No additional DLLs are needed for many standalone Delphi utility programs (but database applications and applications using other tools (e.g., QuickReports) may require additional DLLs).
Deployment of Delphi CLX "Hello World" Windows Application is Fairly Simple
In Delphi 6 or 7, you can create a cross-platform "Hello World" CLX application (File | New | CLX Application) instead of a VCL application. Deployment of the Windows CLX application to other Windows machines is a bit more complicated than the VCL version. In addition to the CLX HelloWorld.EXE, a "QT" DLL, qtintf.dll or qtintf70.dll, is also required. The ~4 MB qtintf.dll file or the ~4 MB qtintf70.dll file can be deployed with the CLX application in the same directory, or copied to where most DLLs are found: C:\Windows or C:\Windows\System according to p.18-6 of the Delphi 7 Developer's Guide. With the Delphi 7 CLX "Hello world" only the qtintf70.dll appears to be sufficient, but Delphi 6 CLX EXEs seem to require the qtintf.dll instead. Download qtintf70.dll from here to run Windows CLX applications from efg's Computer Lab (unzip and put in your Windows directory)..
Deployment of Kylix CLX "Hello World" Linux Application is Not-So-Simple
Deploying a Kylix application under Linux is not quite so simple since certain "shared objects" are needed in addition to the Kylix executable. The Linux platform has many favors (Red Hat, Mandrake, Suse, Debian, ...) and there doesn't appear to be a "standard" Linux environment that is guaranteed to be capable of running a CLX executable without certain versions of shared objects being installed first. [IMHO, this is a sign that Linux is still at the "chaotic" software maturity level since repeatability seems to be so difficult.]
The Kylix 3 Developer's Guide discusses Deployment Issues in Chapter 18 but only gives general guidance on Kylix application deployment. According to this Guide, many Kylix applications are dependent upon a certain set of shared library, which may include:
In addition "Database and Web applications required additional installation steps ...". So, what is needed for the simple Hello World application?
Two approaches are discussed below for running simple, standalone, Kylix applications on a development machine, or other Linux boxes. I have only explored Red Hat alternatives, so problems may exist with various Linux versions.
Kylix Developer Deployment Configuration
If you develop Kylix applications and have Kylix installed on your Linux box, updating the /etc/ld.so.conf file is probably one easy solution to running Kylix applications on the same Linux box. Of course, you must be "root" to perform this change to /etc/ld.so.conf .
The following table shows the location of the "standard" installation of Kylix-related binary files by version:
| Version | "Standard" Installation "bin" Directory |
| Kylix 1 | /usr/local/kylix/bin |
| Kylix 2 | /usr/local/kylix2/bin |
| Kylix 3 | /usr/local/kylix3/bin |
Login as root and add the directory /usr/local/kylixN/bin to the /etc/ld.so.conf file using the editor of your choice.
After modifying /etc/ld.so.conf, run the /sbin/ldconfig program as root to update the /etc/ld.so.cache. On a RedHat Linux 6.2 box, I saw this message that I ignored:
/sbin/ldconfig: warning: /usr/local/kylix3/bin/libborcrtl.so is not a shared libary, skipping
On a RedHat 7.0 and 7.2 boxes, I did not see this same message.
I usually added the /usr/local/kylixN/bin line as the last line of /etc/ld.so.conf . In one case with Kylix 2 Open Edition under RedHat 7.0, there seemed to be some sort of "DLL-like" conflict when trying to run CLX applications. I couldn't get Kylix applications to run until I added the /usr/local/kylixN/bin line as the first line of /etc/ld.so.conf instead of the last line.
With this updated /etc/ld.so.conf file, Kylix executables can be run from the command line preceded by a "./", e.g., ./HelloWorld. I really do not like this "./" notation (try explaining to a scientist why an executable in its current working directory isn't normally in the path, and you're likely to see blank stares as to why anyone would setup things that way). Since I am not that security paranoid, I put "." in my path, reluctantly at the end, via the .bash_profile file with something like this:
export PATH
PATH=$PATH:$HOME/bin:.
Now to run a Kylix executable, I just enter the CLX executable name from the command line.
Deployment to Machine Without Kylix Installed
Unfortunately a number of shared objects are needed to run a CLX application if Kylix is not installed. The "ldd" command will show some of the shared objects that are needed in this Kylix 3 example:
ldd HelloWorld
/lib/libNoVersion.so.1 => /lib/libNoVersion.so.1 (0x40018000)
libX11.so.6 => /usr/X11R6/lib/libX11.so.6 (0x4002c000)
libpthread.so.0 => /lib/i686/libpthread.so.0 (0x4010a000)
libdl.so.2 => /lib/libdl.so.2 (0x4011f000)
libc.so.6 => /lib/i686/libc.so.6 (0x40123000)
/lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x40000000)
All the libraries above are assumed to be part of your Linux system.
In addition, several qt shared objects are needed (assumed to be in ~/kylix/deploy in the discussion below).
These qt files can be found in the "Standard" Kylix Installation "bin" Directory:
libborqt-6.9-qt2.3.so -> libborqt-6.9.0-qt2.3.so*
libborqt-6.9.0-qt2.3.so*libqt.so.2 -> /usr/local/kylix3/bin/libqt.so.2.3.0
libqt.so.2.3.0*libqtintf-6.9-qt2.3.so -> /usr/local/kylix3/bin/libqtintf-6.9.0-qt2.3.so
libqtintf-6.9.0-qt2.3.so*
For Kylix 3 these shared object can be copied from the /usr/local/kylix3/bin directory for deployment on other machines.
Thanks to Angus Johnson for pointing out that not all three of these files are needed at the same time. In Kylix 3, the libborqt by itself is sufficient, or the last twofiles are sufficient, libqt and libqtintf. When the environment variable CLX_USE_LIBQT is set, the last two files, libqt and libqtintf, are used instead of libborqt. But why would I care which approach to use? I'm still not clear why this option exists.
According to the Rick Ross' Deploying Kylix 3 Applications Kylix 3 applications:
A couple of things have changed with Kylix 3. By default, the Qt libraries are loaded dynamically at run-time. Instead of looking for libqt.so, Kylix 3 applications look for libborqt.so. Borland has bundled libqtintf.so and libqt.so in the new libborqt.so. By using libborqt.so, Borland can guarantee that the proper libaries are being loaded. For those who want to use existing Qt libraries (which may or may not be compatible) set the CLX_USE_LIBQT environment variable. (Don't forget to deploy libqtintf.so, though)
Some additional comments from Toni Martir (in a posting to borland.public.kylix.deployment):
CLX_USE_LIBQT=1 -> libttintf+libqt
Without CLX_USE_LIBQT defined-> libborqt only
In my experience some systems only work with CLX_USE_LIBQT enabled, and
other systems only work without CLX_USE_LIBQT defined, so you must
distribute boths.
Having these objects in the same working directory as the executable is not good enough:
./HelloWorld
./HelloWorld: relocation error: ./HelloWorld: undefined symbol: initPAnsiStrings
To use these shared objects either put LD_LIBRARY_PATH in your .bash_profile file, or use a "wrapper" script to establish the LD_LIBRARY_PATH directoy.
LD_LIBRARY_PATH in .bash_profile
Add the following export statement to your .bash_profile (or possibly .bashrc):
export LD_LIBRARY_PATH=~/kylix/deploy
if you have your own local copy, or
export LD_LIBRARY_PATH=/usr/local/kylix3/bin
if you have Kylix installed.
With this export statement, enter the name of the executable to run it (assuming "." is in the path as discussed above):
HelloWorld
LD_LIBRARY_PATH in "wrapper" script
If you don't define LD_LIBRARY_PATH in your .baschrc file, use a wrapper script like this:
cat helloworld.bash
#!/bin/bash
export LD_LIBRARY_PATH=~/kylix/deploy
~/kylix/HelloWorld
Use the "wrapper" to launch the application (assuming "." is in the path):
helloworld.bash &
This approach uses needs only the libborqt shared object. To use the libqt and libqtintf shared objects instead, set the CLX_USE_LIBQT variable:
cat helloworld.bash
#!/bin/bash
export LD_LIBRARY_PATH=~/kylix/deploy
export CLX_USE_LIBQT=1
~/kylix/HelloWorld
Deployment of CLX Applications Downloaded from efg's Computer Lab
The Lab Reports from this web site are intended for two groups, programmers and end users.
Programmers interested in programming details can modify the CLX source code and may not even be interested in the downloaded executable file. Programmers should have few problems since the Delphi/Kylix CLX source programs should work fine from within the Integrated Development Environment (IDE).
End users of the CLX programs used to solve a specific problem, or explore some computer/graphics details, may have some minor problems in the deployment of CLX applications especially in Linux. Unfortunately, the Linux environment is still just a bit too chaotic to make this process repeatable for all the flavors of Linux in the world -- sorry if it doesn't work for you.
After you download a CLX application from efg's Computer Lab, find the additional files below that are necessary to run these applications. Unless otherwise noted, I have only tested such Linux deployment using RedHat 7.0 or 7.2.
Download and get the "Hello World" application working before trying to use other CLX applications from the Computer Lab.
Delphi 7 CLX in Windows 95/98/2000/XP: HelloWorld.zip. (1853 KB including qtintf70.dll)
Unzip this ZIP file into a temporary directory. Execute the HelloWorld.exe since the necessary qtintf70.dll is in the same directory as one of the files unzipped. (Tested in Windows 95, 98, 2000 and XP). Copy qtintf70.dll to C:\Windows or C:\Windows\System if you plan to run multiple CLX applications in Windows.
Kylix 3 CLX in Linux: HelloWorld.tar.gz. (5603 KB including .so files libborqt, libqt, and libqtintf).
Download this file to your home directory (cd ~), and expand the tar.gz with this command (assumes a "kylix" directory does not already exist):
gunzip < HelloWorld.tar.gz | tar xvf -
This command creates a ~/kylix directory with the HelloWorld application and source code, and a ~/kylix/deploy directory with "shared objects" that are needed by CLX applications running in Linux. Until I can figure out why I should use only libborqt instead of libqt and libqtintf, I'll include all three in the HelloWorld.tar.gz file.
Change to the kylix directory, and execute the helloworld.bash script that calls the HelloWorld executable:
cd kylix
./helloworld.bash
Note that this bash script is a wrapper that sets up the LD_LIBRARY_PATH to the ~/kylix/deploy directory that was extracted from the tar file:
cat helloworld.bash
#!/bin/bash
export LD_LIBRARY_PATH=~/kylix/deploy
~/kylix/HelloWorld
Avoid using such wrapper scripts by setting the LD_LIBRARY_PATH or modifying the /etc/ld.so.conf file, as described next.
If you do not have root access, you can run HelloWorld and other CLX applications in Linux from the command line if you put this line in your .bash_profile file:
export LD_LIBRARY_PATH=~/kylix/deploy
If you do have root access, you can run HelloWorld and other CLX applications by adding the ~/kylix/deploy path in absolute form to the /etc/ld.so.conf file. If your absolute path to the deployment directory is /home/earl/kylix/deploy, add this directory as a line in /etc/ld.so.conf, which appears like this on my Linux box:
cat /etc/ld.so.conf
/usr/kerberos/lib
/usr/X11R6/lib
/usr/lib/qt-2.3.1/lib
/home/earl/kylix/deploy
As mentioned above, if you have Kylix installed on your machine (you can download the Kylix "Open Edition" for free from Borland), you can use the Kylix bin directory in /etc/ld.so.conf instead:
/usr/local/kylix3/bin
After modifying /etc/ld.so.conf, run the /sbin/ldconfig
At this point you can execute the HelloWorld program directly instead of using the wrapper script:
~/kylix/HelloWorld
or
cd ~/kylix
./HelloWorld
The "./" in the last statement can be dropped by adding "." to your path in your .bash_profile file:
export PATH
PATH=$PATH:$HOME/bin:.
Finally, in the ~/kylix directory, this simple application can be executed with only
HelloWorld
Other Delphi/Kylix CLX Deployment Links
File "DEPLOY" on the Kylix CD gives legal details about which files can be legally redistributed
Chapter 18, Deploying applications, in Kylix 3 Developer's Guide
Chapter 18, Deploying applications, in Delphi 7 Developer's Guide
Newsgroup: borland.public.kylix.deployment
Creating Kylix Database Applications
http://bdn.borland.com/article/images/28558/kylix_dbapps.pdf
Rick Ross' Deploying Kylix 3 Applications
www.rick-ross.com/papers/k3/k3deploy.html
Updated 25 Feb 2003
since 14 Oct 2002