[ fromfile: setup-nix.xml id: setup-nix ]
Open source development tools (ssh, bash, gcc) are available natively on UNIX and their related platforms.
This includes Mac OS/X, which is a BSD-based distribution. [84]
When we discuss something that's specific to UNIX-derived platforms (Linux, BSD, Solaris, etc), we will use the shorthand *nix for “most flavors of UNIX.“
Another important acronym is POSIX, which stands for Portable Operating System Interface for UNIX. The development of this family of application programming interface (API) standards was sponsored by the IEEE (Institute of Electrical and Electronics Engineers), an organization for engineers, scientists, and students, best known for developing standards for the computer and electronics industry. [85]
This section is for readers who are using a computer with some flavor of *nix installed.
The examples in this book were tested with Qt 4.4. We recommend that you use the same version or a later one. The first step in setting up your computer for this book is to make sure that the full installation of Qt 4 is available to you. This includes, in addition to the source and compiled library code, the Qt Assistant documentation system, program examples, and the Qt Designer program.
| Note | |
|---|---|
If your system has KDE 3.x (the K Desktop Environment) installed, then there is already a runtime version of Qt 3.x installed. Qt 4 needs to be installed separately. Our examples do not compile under Qt 3. |
To see which (if any) version of Qt has already been installed on your system, start with the commands:
which qmake qmake -v
The output of the first command tells you where the qmake executable is located.
If that output looks like this: bash: qmake: command not found, it is possible that:
The “full” Qt (including development tools) is not installed.
It is installed, but your PATH does not include /path/to/qt4/bin
It is installed by your package manager as qmake-qt4, to avoid conflict with same-named executables from Qt3.
If you can run it, qmake -v provides version information.
If it reports Using Qt version 4.x.y, check whether these other Qt tools are available: moc, uic, assistant, and designer.
If these executables are all found and match versions, Qt 4 is installed and ready to use.
If the tests outlined above indicate that you have an earlier version or no Qt installed, or that you are missing some components of Qt 4, then you will need to build or install the latest release of Qt 4, and select the qt4 executables as defaults in your path.
You can download, unpack, and compile the latest open source tarball from Trolltech.
Two typical places to unpack the tarball are /usr/local/ (if you are root) or $HOME/qt (if you are not).
| Installing dependencies | |
|---|---|
In Debian, it is possible with a single command to automatically install all of the tools and libraries you need to build another Debian package. You can take advantage of this, when you want to build any popular open-source tool from source. For more information, see Appendix D. apt-get build-dep libqt4-dev |
| Note | |
|---|---|
A tarball is a file produced by the The command line for unpacking a tarball depends on how it was created. You can usually determine this from its extension. tar -vxf whatever.tar // uses the "verbose" switch tar -zxf whatever.tar.gz // compressed with gzip tar -zxf whatever.tgz // also compressed with gzip tar -jxf whatever.tar.bz2 // compressed with bzip2 A tar file can preserve directory structures and has many options and switches. You can read the online documentation for these utilities by typing: info tar info gzip info bzip
|
The Qt source tarball contains the complete source code of the Qt library, plus numerous examples, tutorials, and extensions with full reference documentation.
The tarball contains simple installation instructions (in the README and INSTALL files) and a configure --help message.
Be sure to read the README file before you attempt to install software from any open source tarball.
Compiling from source can take 2 to 3 hours (depending on the speed of your system), but it is worth the time. Example E.1 shows the options we use to configure Qt 4.
Example E.1. ../bin/qtconfigure
#!/bin/sh # specify -phonon if you want to build the mp3player exercise or any of the Phonon examples. # See README.txt in libs/mp3player for details. ./configure -phonon -system-sqlite -verbose # make
After Qt is configured, make and then install it.
| Tip | |
|---|---|
If you have a multi-core processor, try supplying a |
In the final step, make install copies the executables and headers into another location from the unzipped tarball source tree. If you are installing in a common location, you need to be root to do this.
| Tip | |
|---|---|
After installation, try [ezust@stan] /home/ezust> which qmake /usr/local/Trolltech/Qt-4.4.1/bin/qmake [ezust@stan] /home/ezust> qmake -version QMake version 2.01a Using Qt version 4.4.1 in /usr/local/Trolltech/Qt-4.4.1/lib |
After installing, check your environment variables and make sure that your PATH and LD_LIBRARY_PATH contain proper references to the built installed Qt.
We use a variable called QTDIR to hold path to the main directory of the Qt 4 installation [86].
PATH must have $QTDIR/bin (the path to the Qt executables).
LD_LIBRARY_PATH contains $QTDIR/lib (the path to the Qt libraries).
Optional: MANPATH should contain $QTDIR/doc (the path to the Qt documentation).
| Tip | |
|---|---|
The |
Example E.2 shows how we set the values with bash, but the actual values depend on where the files are located on your system.
Example E.2. src/libs/utils/qt.sh
# Typical user specific environment and startup values for QT # depending on how and where qt was installed on your system export QTDIR=/usr/local/Trolltech/Qt-4.4.1 export PATH=$QTDIR/bin:$PATH export MANPATH=$QTDIR/doc/man:$MANPATH # Location of your own libraries - source and target. export CPPLIBS=~/cs331/projects/libs # LD Library path - where to search for shared object libraries # at runtime. export LD_LIBRARY_PATH=$CPPLIBS:$QTDIR/lib:$LD_LIBRARY_PATH
[84] BSD stands for Berkeley Software Distribution, a facility of the Computer Systems Research Group (CSRG) of the University of California at Berkeley. CSRG has been an important center of development for UNIX and for various basic protocols (e.g., TCP/IP) since the 1980s.
[85] If we wanted to write a POSIX regular expression (Section 14.3), for *nix, it might look like this:
(lin|mac-os|un|solar|ir|ultr|ai|hp)[iu]?[sx].
[86] Qt 4 does not require the use of this environment variable but we use it to refer to the “Qt install” directory in our examples.
| Generated: $Date: 2009-09-08 12:15:32 -0400 (Tue, 08 Sep 2009) $ | © 2009 Alan Ezust and Paul Ezust. |