They apply to the provided examples as well as to your own programs.
.pro
.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. It can be simplified for your projects. 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 #include
s 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.
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 INCLUDEPATH *= C:/Users/debunne/Documents/libQGLViewer-2.3.6 # Windows LIBS *= -LC:/Users/debunne/Documents/libQGLViewer-2.3.6/QGLViewer -lQGLViewer2 # Linux LIBS *= -L/home/debunne/libQGLViewer-2.3.6/QGLViewer -lQGLViewer # Mac if you compiled a framework in /Library/Frameworks (default) LIBS *= -framework QGLViewer
cd path\to\myApp qmake mingw32-make myAppSome
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 were installed in C:\Program Files\libQGLViewer\examples
.
.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.
See also the advices for libQGLViewer installation on Windows.
.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
.
cd path/to/myApp qmake make myApp
-Wl,-rpath
in the compilation options should make your executable find the library. In case you are prompted with an error while loading shared libraries
message when executing the program, fix the path.
An other option is to 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
, 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 the Qt-Unix and libQGLViewer on Unix installation pages.
cd path/to/myApp qmake -spec macx-xcodeThen open and build the resulting Xcode project.
make
cd path/to/myApp qmake -spec macx-g++ make myApp
open myApp.pro
install_name
to set its path in your program.
Read Apple's "Creating a Framework" as well as Qt's "Deploying an Application on Mac OS X" guides for details.
Tune theQMAKE_LFLAGS
variable if the library was not installed in the default /Library/Frameworks
directory. Use the
LIBS *= -L/path/to/lib -lQGLViewer
Unix syntax if you compiled a dylib instead of a framework.
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.