Home Download Gallery Documentation Developer

# libQGLViewer installation
Unix systems

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

## Mac OS X

Download and decompress the sources, then open the `libQGLViewer-2.6.1/QGLViewer` folder.

### Using Qt Creator

Open `QGLViewer.pro` and "build all".

### Using Xcode

Create the Xcode project by running these lines in a terminal:

    cd path/to/libQGLViewer-2.6.1/QGLViewer
    qmake -spec macx-xcode

### Using `make`

    cd path/to/libQGLViewer-2.6.1/QGLViewer
    qmake -spec macx-g++
    make

See the Linux section for details and install paths customization.

### Next steps

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

Install the libQGLViewer designer plugin to easily create user interfaces that integrate a QGLViewer using designer.

You can `make install` to install the documentation in `/Developer/Documentation/QGLViewer`.

A Framework is created by default. Uncomment a line in `QGLViewer.pro` if you want to create a `.dylib` instead.

## Qt installation on Mac

Install Qt from the nokia web site. Then use the provided Qt Creator or download Xcode from the apple web site.

## Linux and Unix

Download and decompress the sources, then go to the `libQGLViewer-2.6.1/QGLViewer` folder.

    tar -xzf libQGLViewer-2.6.1.tar.gz
    cd libQGLViewer-2.6.1/QGLViewer

### Using Qt Creator

Open `QGLViewer.pro` and "build all". Optionaly `make install` to install the application system wide.

### Using `make`

    qmake (see options below)
    make
    sudo make install [optional]

The following files are installed (you need root privileges to `install`, since these are system directories):

- The library (`libQGLViewer-2.6.1.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`

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

The `QGLVIEWER_STATIC=yes` 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

Qt is probably already installed on your machine, or available on your distribution's repository. You may however have to install the `dev` development package. You can also directly download it.

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

## 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 entry 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.

Edit the `qglviewerPlugin` code as indicated to create a similar designer plugin for your derived QGLViewer class.

To compile and install the 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. 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 Wednesday, June 24, 2015.