[ fromfile: setup-nix.xml id: setup-nix ]
Open source development tools (ssh
, bash
, gcc
) are available natively on most UNIX-derived platforms.[132]
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.[133]
This section is for readers who use a computer with a *nix system installed.
The first step to prepare your computer for this book is to make sure that the full installation of Qt 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.
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/qt/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
, use the which
command to check whether these other Qt tools are available: moc, uic, assistant, designer
, and qtcreator
.
If these executables are all found and match versions, Qt is installed and ready to use.
If these tests indicate that you have an earlier version or no Qt installed, or that you are missing some components of Qt, then you need to build or install the latest release of Qt and select the Qt executables as defaults in your path.
You can download, unpack, and compile the latest open source tarball from qt.nokia.com. If you have the Qt SDK, you can run the Updater and select , to download it into your Qt SDK directory. Be sure to also select demos and examples.
Installing dependencies | |
---|---|
In Debian, it is possible with a single command to automatically install all 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 used to configure Qt 4.7.
Example E.1. ../bin/qtconfigure
#!/bin/sh
# specify -phonon if you want to build the audiojukebox exercise or
any of the Phonon examples.
# replace username with your username, and Qt473 with your version of
Qt
./configure -phonon -debug-and-release -fast
After Qt is configured, type make
and then install it.
Tip | |
---|---|
If you have a four-core processor, try typing make -j 4 and the compiler will run four compile processes simultaneously, taking full advantage of your extra cores. |
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, type the command [ezust@stan] /home/ezust> which qmake which qmake /usr/local/Trolltech/QtSDK/Desktop/Qt/473/gcc/bin/qmake [ezust@cerberus] /home/ezust> qmake -version QMake version 2.01a Using Qt version 4.7.3 in /usr/local/Trolltech/QtSDK/Desktop/Qt/473/gcc/lib |
After installing, check your environment variables and make sure that your PATH
contains proper references to the built installed Qt.
Tip | |
---|---|
The |
Example E.2 shows how you can
set the values of environment variables with bash
, but the actual values depend on
where the files are located on your system.
Example E.2. ../bin/qt.sh
# Using the Qt SDK 1.1 # None of the variables below are required by Qt # I just like having variables pointing to these locations for easy access: export QTSDK=/opt/QtSDK export QTCREATOR=$QTSDK/QtCreator export QTDIR=$QTSDK/Desktop/Qt/473/gcc export QTSRC=$QTSDK/QtSources/4.7.3 # make sure SDK's qmake and qtcreator are found first in the path: export PATH=$QTDIR/bin:$QTCREATOR/bin:$PATH # Location of your shared libraries: export CPPLIBS=~/cs331/projects/libs # Where to search for shared object libraries at runtime: export LD_LIBRARY_PATH=$CPPLIBS
[132] On Mac OSX, you need to
install xcode to get the C++ compiler and make
tool.
[133] If we want 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]
.
Generated: 2012-03-02 | © 2012 Alan Ezust and Paul Ezust. |