Home Documentation Download Examples Developer

# libQGLViewer installation
Unix systems

» Installation on Linux and Unix: libQGLViewer and Qt
» Installation on Mac: libQGLViewer and Qt
» QGLViewer designer plugin installation
» Troubleshooting

## Linux and Unix

The following files are installed:

- The library (`libQGLViewer-2.3.5.so`) in `/usr/lib`
- The header files and designer plugin code in `/usr/include/QGLViewer`
- The documentation and the examples in `/usr/share/doc/QGLViewer`

### Debian/Ubuntu packages

libQGLViewer is available as a debian package (many thanks to Artur). It should be available from standard debian depositories and can be installed using your usual package manager.

As an alternative, you can use these debian packages generated using Alien and depending on the latest Qt version :

    apt-get install libqglviewer_2.3.5_i386.deb libqglviewer-devel_2.3.5_i386.deb

### RPM packages

Use the following command line:

    rpm -Uvh libQGLViewer-2.3.5.i386.rpm libQGLViewer-devel-2.3.5.i386.rpm

You can also re-compile the RPM for optimal results:

    rpmbuild --rebuild libQGLViewer-2.3.5.src.rpm
    cd /usr/src/RPM/RPMS/i?86/ (or /usr/src/redhat/RPMS/i?86, see the rpmbuild last log lines)
    rpm -Uvh libQGLViewer-*2.3.5.i?86.rpm

Change the RPM installation prefix, say to `/usr/local` (default is `/usr`), using `rpm -Uvh --prefix /usr/local ...`.

### FreeBSD

Use the FreeBSD port.

### Compilation and installation

You can also compile the library from its source tarball:

    tar -xzf libQGLViewer-2.3.5.tar.gz
    cd libQGLViewer-2.3.5/QGLViewer
    qmake (see options below)
    make
    make install

You need root privileges to install the library, since default install paths are system directories.

Optional `qmake` parameters let you customize your `make install` target installation directories:

    qmake [PREFIX=...] [INCLUDE_DIR=...] [LIB_DIR=...] [DOC_DIR=...] [QGLVIEWER_STATIC=yes]

A typical usage would be `qmake PREFIX=$HOME`. Default values are:

    - Param -      - Default value -
    PREFIX         /usr
    LIB_DIR        PREFIX/lib
    INCLUDE_DIR    PREFIX/include
    DOC_DIR        PREFIX/share/doc

When set, the `QGLVIEWER_STATIC` qmake option will compile a static version of the library.
If your Qt version is lower than 3.1, you need to link with the `glut` library: uncomment a line in `QGLViewer.pro` as explained there. `glut` can be installed from the `freeglut-devel` rpm or using `apt-get install libglut3-dev`.

### Next steps

Once the library is compiled, you can compile the examples.

You may also want to install the libQGLViewer designer plugin to easily create user interfaces that integrate a QGLViewer using designer.

## Qt installation on Linux

You need to have the Qt library installed in order to run libQGLViewer. Qt is probably already installed on your machine, or available on your distribution CDs. You may however have to install the `dev` development package.

Try to compile a simple Qt example and check the Qt FAQ page in case of problem. Consider compiling one of the Qt OpenGL examples to test your configuration.

With Qt version 3, you need to set some shell variables. If your shell is `bash` or `zsh` (use `echo $SHELL` to know), add these lines to your `.profile`:

    export QTDIR=/usr/lib/qt3 (or /usr/lib/qt-3.3 or /usr/share/qt...)
    export PATH=${PATH}:${QTDIR}/bin
    export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:${QTDIR}/lib

If you use `tcsh` or `csh` instead, add these lines to your `.login`:

    setenv QTDIR /usr/lib/qt3 (or /usr/lib/qt-3.3 or /usr/share/qt...)
    setenv PATH ${PATH}:${QTDIR}/bin
    setenv LD_LIBRARY_PATH ${LD_LIBRARY_PATH}:${QTDIR}/lib

Source this file or open a new shell to take these values into account. If you installed `libQGLViewer` in a custom directory, add the path to this directory in `LD_LIBRARY_PATH` as is done above for `${QTDIR}/lib`.

## Mac OS X

### Using Xcode

    tar -xzf libQGLViewer-2.3.5.tar.gz
    cd libQGLViewer-2.3.5/QGLViewer
    qmake -spec macx-xcode

Then open and build the resulting Xcode project. Run `make install` to install the documentation in `/Developer/Documentation/QGLViewer`.

### Using `make`

The installation procedure is essentially identical to the one described in the Linux section:

    tar -xzf libQGLViewer-2.3.5.tar.gz
    cd libQGLViewer-2.3.5/QGLViewer
    qmake -spec macx-g++
    make
    make install

See the Linux section for details and install paths customization.

### Next steps

Xcode and `make` both generate a Framework by default. Uncomment a line in `QGLViewer.pro` to create a `.dylib` instead.

Once the library is installed, you can compile the examples.

With Qt3, threads are activated with the `darwin-g++` version and disabled with `macx`. Add or remove `thread` in the `CONFIG` section of `.pro` files if this does not correspond to your Qt configuration.

If your Qt version is lower than 3.1, you need to link with the `glut` library. Install `glut` and uncomment a line in `QGLViewer.pro` as explained.

## Qt installation on Mac

The easiest way to develop Qt applications on a Mac is to download Xcode from the apple web site and then to install a Qt package from the nokia web site.

## Installation of the designer plugin

The designer plugin installation is optional. It eases the creation of user interfaces that feature a QGLViewer using Qt's designer. It adds a QGLViewer icon in the designer's `Display Widgets` tab:

When added to your interface, the widget displays the standard spiral, which can be manipulated when you test it. All the viewers' signals and slots are available and can be connected to your interface. Start from this code to create your own designer plugin for your derived QGLViewer classes.

To compile and install the QGLViewer designer plugin, simply do:

    cd designerPlugin
    qmake
    make
    make install

The `designerPlugin` directory is located in the tarball root directory or in `/usr/include/QGLViewer/designerPlugin` if you installed QGLViewer from the RPM.

By default, the plugin is installed in `QTDIR/plugins/designer` which is usually a system directory. The `make install` step hence requires root privileges. With Qt4, you can customize the plugin installation path using the `qmake PREFIX=...` syntax instead. Do not forget to add this path to your `QT_PLUGIN_PATH` variable so that designer can find the plugin.

Note that `libQGLViewer.so` needs to be found by `designer` in order to load the plugin. If you didn't `make install` the library, add the path to the `.so` (resp `.dylib` with Mac) in your `LD_LIBRARY_PATH` (resp. `DYLD_LIBRARY_PATH`) as explained in the Qt installation sections above.

With Qt version 3, an alternative to this plugin is to add a "Custom Widget" using the Tools/Custom designer menu. Load Descriptions... and to provide the `qglviewer.cw` custom widget description file, located in the QGLViewer header files directory. You can then set the header file path to your customized QGLViewer and add your own signals and slots to the description.

See the interface example for an illustration of a Qt user interface that includes a QGLViewer.

## Troubleshooting

Here are some error messages that you may encounter with their solutions:

- QWidget: Must construct a QApplication before a QPaintDevice.: the library and your program were probably compiled in debug and release modes (or vice-versa). Using the same mode for both should fix this problem (may also appear with static vs dynamic libraries).
- declaration of `qtObsolete` conflicts with previous declaration: error message. See the mac example section.
- uic: File generated with too recent version of Qt Designer: try to change the `version="..."` in the first line of the `ui` file.
- Error while loading shared libraries: add the path to `libQGLViewer.so` in your `LD_LIBRARY_PATH` (see above).
- Random or no display: this may come from a bug in your compiler. Try to edit `QGLViewer.pro`, replace `release` by `debug` in the `CONFIG` line, and re-compile.
- lib3ds: this library is needed to compile the 3dsViewer example. Download the patched lib3ds-1.2.0-1.i686.rpm or the sources (lib3ds-1.2.0-1.src.rpm or lib3ds-1.2.0.tar.gz).
- The indicated type is incomplete error message in `qvaluevector.h` while compiling `keyFrameInterpolator.cpp`: include `frame.h` (see top of `keyFrameInterpolator.cpp`).
- overloading cannot distinguish from previous declaration: while compiling `translate` and `rotate` in `Frame.h`. Simply comment the `const` versions of these methods.
- cp: illegal option -- P: this option is very useful but may not be available on your machine. Remove the `QMAKE_COPY_FILE` modification in `QGLViewer.pro`
- gcc 2.95: ostream operator << with `QString`: uncomment the patch in `config.h`
- Undefined reference to QString::QString (Qt3): add/remove `thread` in the `CONFIG` line of `QGLViewer.pro` and re-compile.
- exception handling disabled: add `QMAKE_CXXFLAGS *= -fexceptions` in `QGLViewer.pro`.

Please let me know if you encounter specific installation problems.

Last modified on Sunday, February 28, 2010.