SoQt Build Instructions for Linux - magic-lantern-studio/mle-documentation GitHub Wiki
This page descibes how to build the SoQt GUI for Coin 3D.
Table of Contents
Qt Build Instructions
SoQt depends upon the the Qt libraries. For Linux, you must first build the Qt source and then install the libraries from the local build.
Dependencies
Qt has the following dependencies:
sudo apt-get install libfontconfig1-dev libfreetype6-dev libx11-dev libxcursor-dev libxext-dev libxfixes-dev libxft-dev libxi-dev libxrandr-dev libxrender-dev
Building from tar Package
The Qt package can be downloaded from the Qt Downloads archive: https://download.qt.io/archive/qt/4.8/4.8.6/. The package is qt-everywhere-opensource-src-4.8.6.tar.gz.
Unpack the tar File
Do the following to extract the source:
tar -xvzf qt-everywhere-opensource-src-4.8.6.tar.gz
Configure the Build Directory
Build the libraries and distribution elements (i.e. documentation and tools). Be sure to enable the HTML and man page generation.
cd qt-everywhere-opensource-src-4.8.6
./configure --enable-html --enable-man
Build the Qt Libraries and Tools
Build the libraries and tools using:
make
Install the Qt Libraries and Tools
To install the libraries and tools
make install
The build artifacts will be installed in /usr/local/Trolltech/Qt-4.8.6/.
Set QTDIR Environment Variable
Set the QTDIR environment variable to /usr/local/Trolltech/Qt-4.8.6/.
export QTDIR=/usr/local/Trolltech/Qt-4.8.6.
Update PATH Environment Variable
Update the PATH environment variable to locate the Qt tools.
export PATH=$QTDIR/bin:$PATH
SoQt Build Instructions
These instructions focus on building the SoQt GUI library from a tar distribution package. The instructions are geared towards an Ubuntu 14.04 LTS host development platform.
Dependencies
SoQt has the following dependencies:
- Qt v4.8.6 - see build and installation instructions above.
Building from tar Package
The SoQt package can be downloaded from the Bitbucket account: https://bitbucket.org/Coin3D/coin/downloads. The package is SoQt-1.5.0.tar.gz.
Unpack the tar File
Do the following to extract the source:
tar -xvzf SoQt-1.5.0.tar.gz
Configure the Build Directory
Build the libraries and distribution elements (i.e. documentation) in a separate directory. Be sure to enable the HTML and man page generation.
mkdir soqt-build
cd soqt-build
../SoQt-1.5.0/configure --enable-html --enable-man
Build the SoQt Library
Build the SoQt library, libSoQt.so:
make
Install the SoQt Library
To install the library, header files and documentation, do the following:
make install
The library will be installed in /usr/local/lib/libSoQt.so. The header files will be installed in the /usr/local/include directory. HTML pages are populated in the /usr/local/share/doc/soqt/html directory. The manual pages are installed into /usr/local/man.
Viewer Example Code
The following is an example on how to use the SoXt library:
#include <Inventor/Qt/SoQt.h>
#include <Inventor/Qt/viewers/SoQtExaminerViewer.h>
#include <Inventor/nodes/SoBaseColor.h>
#include <Inventor/nodes/SoCone.h>
#include <Inventor/nodes/SoSeparator.h>
int
main(int argc, char ** argv)
{
// Initializes SoQt library (and implicitly also the Coin and Qt
// libraries). Returns a top-level / shell Qt window to use.
QWidget * mainwin = SoQt::init(argc, argv, argv[0]);
// Make a dead simple scene graph by using the Coin library, only
// containing a single yellow cone under the scenegraph root.
SoSeparator * root = new SoSeparator;
root->ref();
SoBaseColor * col = new SoBaseColor;
col->rgb = SbColor(1, 1, 0);
root->addChild(col);
root->addChild(new SoCone);
// Use one of the convenient SoQt viewer classes.
SoQtExaminerViewer * eviewer = new SoQtExaminerViewer(mainwin);
eviewer->setSceneGraph(root);
eviewer->show();
// Pop up the main window.
SoQt::show(mainwin);
// Loop until exit.
SoQt::mainLoop();
// Clean up resources.
delete eviewer;
root->unref();
return 0;
}