E.1.  C++/Qt Setup: Open Source Platforms

[ fromfile: setup-nix.xml id: setup-nix ]

which qmake
qmake -v
  1. The "full" Qt (including development tools) is not installed.

  2. It is installed, but your PATH does not include /path/to/qt/bin

  3. It is installed by your package manager as qmake-qt4, to avoid conflict with same-named executables from Qt3.

Downloading from Source

[Tip] 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

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

[Tip]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.

Checking Qt's installation

[Tip]Tip

After installation, type the command qmake -v to determine which version of qmake is found by your shell. For systems that have more than one version installed, this is especially important to do.

[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

Environment Variables

[Tip]Tip

The bash command env displays the current values of all your environment variables. Environment variables are discussed and used in Section 7.2.

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



[98] On Mac OSX, you need to install xcode to get the C++ compiler and make tool.