myApp.pro project file.
Compilation on WindowsmyApp.pro in Qt Creator then compile and run.
makecd path\to\myApp qmake mingw32-make myApp
.pro file. All parameters should be properly configured and your program should compile.
Make sure you link with the Release version of Qt if you build in Release mode.
.dsp generated by qmake from the .pro.
QGLViewer2.dllQGLViewer2.dll (or QGLViewer2d.dll in debug mode) has to be found in order to execute your application.
C:\Windows\System32,set PATH=%PATH%;C:\Users\...\libQGLViewer-2.6.3\QGLViewer\release
Compilation on MacmyApp.pro in Qt Creator then compile and run.
cd path/to/myApp qmake -spec macx-xcode open myApp.xcodeprojThen compile your project.
makecd path/to/myApp qmake -spec macx-g++ make open myApp.app
~/Library/Frameworks, where it can be
accessed from any application.
Use install_name and read Apple's
"Creating a Framework"
as well as Qt's "Deploying an Application on Mac OS X" if you customize your path.
LIBS *= -L/path/to/lib -lQGLViewer Unix syntax if you compiled a dylib instead of a framework.
myApp.pro in Qt Creator then compile and run.
makecd path/to/myApp qmake make ./myApp
-Wl,-rpath syntax so that your executable finds the library.
In case you are prompted with an error while loading shared libraries message when executing the program, fix that path.
An other option is to copy libQGLViewer.so (created when you compiled the QGLViewer library) to your app's directory,
or (better) move it to a standard library directory (such as /usr/lib, as is done when you make install).
LIBS *= -lXi in the .pro file.
Debian users may have to replace -lQGLViewer by -lQGLViewer-2 in their .pro.
See also how to customize your .pro or the libQGLViewer on Unix installation page.
.pro for your application
Qt uses a .pro file to tune the compilation settings. The one that comes with the examples is pretty involved since it
tries to automatically detect where the library and headers files are located. There is no need to change it: the examples should compile out of the box.
.pro for your own projects. You need to set these three important variables in order to use libQGLViewer:
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 the /xxx/yyy/QGLViewer directory, 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). Use -framework QGLViewer instead if you compiled a Framework instead of a dylib on Mac (default).
QT which lists the required Qt modules: QT *= opengl xml is a minimum..pro (change the paths according to your configuration):
TARGET = myViewer CONFIG *= qt opengl release QT *= opengl xml HEADERS = myViewer.h SOURCES = myViewer.cpp main.cpp # Windows INCLUDEPATH *= C:/Users/login/Documents/libQGLViewer-2.6.3 LIBS *= -LC:/Users/login/Documents/libQGLViewer-2.6.3/QGLViewer -lQGLViewer2 # Linux INCLUDEPATH *= /home/login/Documents/libQGLViewer-2.6.3 LIBS *= -L/home/login/libQGLViewer-2.6.3/QGLViewer -lQGLViewer # Mac INCLUDEPATH *= /Users/login/Documents/libQGLViewer-2.6.3 LIBS *= -F/Users/login/Library/Frameworks -framework QGLViewer
.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.
fatal error C1083: 'QDomElement' : No such file or directory is fixed by adding
XML library and OpenGL library in Project - Add Qt module.
draw() method to define your own scene.
Overload the init() function to initialize your scene as well as the OpenGL state (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 functionalities 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\\login\\Documents\\Code\\libQGLViewer\\QGLViewer"); // for instance
QGLViewer translation files are available in the QGLViewer's header directory.
Please let me know if you encounter any problem following this guide.