They apply to the provided examples as well as to your own programs (whose code will probably start from one of these, simpleViewer
being the simplest one).
.pro
.pro
file in Qt. The one that comes with the examples should not need to be modified. It is pretty involved since it
tries to automatically detect a number of parameters, and it can be simplified. The three important variables that have to be set in order to
use libQGLViewer are:
INCLUDEPATH
which must indicates where to find the QGLViewer's include files. Since the includes use a QGLViewer/qglviewer.h
syntax,
the QGLViewer
suffix should be omitted in this path: If libQGLViewer was installed in a directory such as /xxx/yyy/QGLViewer
, you will set this variable to INCLUDEPATH *= /xxx/yyy
.LIBS
which tells that your program links with libQGLViewer. Use LIBS *= -L/path/to/lib -lQGLViewer2
, where /path/to/lib
is the path to the libQGLViewer lib, named libQGLViewer2.{so|a|dylib}
or QGLViewer2.lib
depending on your architecture.
QT
which lists the Qt modules needed : QT *= opengl xml
..pro
(change the paths according to your configuration):
TARGET = simpleViewer CONFIG *= qt opengl release QT *= opengl xml HEADERS = simpleViewer.h SOURCES = simpleViewer.cpp main.cpp INCLUDEPATH *= C:/Users/debunne/Documents/libQGLViewer-2.3.4 LIBS *= -LC:/Users/debunne/Documents/libQGLViewer-2.3.4/QGLViewer -lQGLViewer2
Using the Qt OpenSource edition with MinGW
> cd path\to\simpleViewer > qmake > make > simpleViewerSome
dll
s need to be found in order to run your program :
QGLViewer2.dll
, which has been created when you compiled the QGLViewer library.QtCore4.dll, QtGui4.dll, QtOpenGL4.dll
and QtXml4.dll
), which standard location is C:\Qt\4.x.x\bin
.mingwm10.dll
, usually located in C:\Program Files\MinGW\bin
.C:\Windows\System32
.
If you used the libQGLViewer installation package, these dll
s are available (standard installation path is C:\Program Files\libQGLViewer\examples
).
Using the Qt Commercial edition with Visual Studio integration
.pro
file. All parameters should be properly configured, and your program should compile.
See the comment in the above section about dll
s if you have an error when starting your program.
.pro
, you can add the QGLViewer's headers path (without the trailing QGLViewer
) to C/C++ / General / Additional Include Directories
and add QGLViewer2.lib
to the Linker / Input / Additional Dependencies using the project properties.
These settings can also be shared by all your projects by setting the Tools / Options / Directories Include and Library values.
A fatal error C1083: 'QDomElement' : No such file or directory
is fixed by adding
XML library
and OpenGL library
in Project - Add Qt module.
.dsp
generated by qmake
from the .pro
.
See also the advices for libQGLViewer installation on Windows.
Using the Unix command line, the compilation is as simple as:
> cd path/to/simpleViewer > qmake > make > simpleViewer
error while loading shared libraries
message when executing the program.
Either copy libQGLViewer.so
(created when you compiled the QGLViewer library) to this directory,
or (better) move it to a standard library directory (such as /usr/lib
, asis done when you make install
).
libQGLViewer.so
to
your default library path (use LD_LIBRARYN32_PATH
instead on some Unix flavors):
[bash] > export LD_LIBRARY_PATH=\${LD_LIBRARY_PATH}:/.../.../... [tcsh] > setenv LD_LIBRARY_PATH \${LD_LIBRARY_PATH}:/.../.../...Some configurations may require you to add
LIBS *= -lXi
in the .pro
file.
Debian users may have to replace -lQGLViewer
by -lQGLViewer-2
in their .pro
.
See also the Qt-Unix and libQGLViewer on Unix installation pages.
The compilation on Mac is essentially identical to the one described above in the linux section (
libQGLViewer.so
is named libQGLViewer.dylib
instead).
Simply replace the above lines by:
[bash] > export DYLD_LIBRARY_PATH=\${DYLD_LIBRARY_PATH}:/.../.../... [tcsh] > setenv DYLD_LIBRARY_PATH \${DYLD_LIBRARY_PATH}:/.../.../...You can safely ignore the prebound warning. Building a prebound library creates overlapping address ranges. This requires further investigations and any help is more than welcome.
If you get a declaration of C function 'void qObsolete' conflicts with previous declaration
or a
template with C linkage
error message, try to install libQGLViewer somewhere else:
cd QGLViewer make uninstall qmake INCLUDE_DIR=/usr/local/include (for instance) make installTune your
.pro
accordingly and recompile your program. Any
explanation or cleaner solution is more than welcome.
See also the Qt-Mac and libQGLViewer on Mac installation pages.
draw()
method to define your own scene.
Overload the init()
function to initialize your scene as well as the OpenGL parameters (such as textures and objects).
Read the principles of the library for details. If not already done, try out the
different examples and feel free to cut and paste code for the functionnalities you need.
main
method to translate the texts of your interface.
QApplication application(argc,argv); QString locale = QLocale::system().name(); QTranslator translator; translator.load(QString("qglviewer_") + locale); // translator.load(your application specific translation file(s)); app.installTranslator(&translator);This assumes that
qglviewer_*.qm
is located in your application directory. If it is not the case, copy it or use the overloaded load
method:
translator.load(QString("qglviewer_") + locale, "C:\\Users\\debunne\\Documents\\Code\\libQGLViewer\\QGLViewer"); // for instanceQGLViewer translation files are available in the QGLViewer's header directory.
Please let me know if you encounter any problem following this guide.