Opengl doesn't work with Qt
-
-l stands for library and -L for library path, see "qmake doc":http://doc.qt.nokia.com/4.7/qmake-variable-reference.html#libs
[quote author="fery13" date="1309197219"]Yes I am using in plain C++ without problem,
But I can not find any file like lglut in my pc(where can I get this file) ??????
I have only glut, glut32 (header file and lib file ).... [/quote] -
-lglut is like a command line option, which you use to tell qmake to use a library. -l is the option and glut the argument. On Windows, the file should be called glut.lib. -L is used to add a directory in which to look for libraries.
I don't think this is the problem, though. It seems to find GLUT and is unable to link with it. Maybe you simply cannot do this, because using those functions mentioned above together with Qt really makes no sense.
-
That's strange I tried all, but still errors, also I re install Qt ... here is my .pro:
@
#-------------------------------------------------Project created by QtCreator 2011-06-23T18:42:17
#-------------------------------------------------
TARGET = open1
TEMPLATE = app
DEPENDPATH += .
INCLUDEPATH += .
SOURCES += open1.cpp
HEADERS += open1.h
open1_global.hCONFIG += opengl
releaseQT += opengl
LIBS += -lglut
LIBS += C:\Users\FGHASSEMIT\Documents\qt\GL\glut.lib
@
and here errors ::-1: error: cannot find -lglut
:-1: error: collect2: ld returned 1 exit status.................
this is the same if I write glut32 instead of glut ....
:(Edit: Added @ tags
-
You are now trying to link with glut twice... Your .pro file should contain
@
LIBS += -lglut
LIBS += -LC:\Users\FGHASSEMIT\Documents\qt\GL
@
or just
@
LIBS += C:\Users\FGHASSEMIT\Documents\qt\GL\glut.lib
@
but not both.Nevertheless, I think you should try to get rid of the glut dependency, because using it with Qt will most likely create problems.
-
sorry I forget to put dash (-) behind so the errors turn to be like this :
C:\Users\FGHASSEMIT\open1\open1.cpp:-1: error: undefined reference to
__glutInitWithExit' C:\Users\FGHASSEMIT\open1\open1.cpp:-1: error: undefined reference to
glutInitDisplayMode'
C:\Users\FGHASSEMIT\open1\open1.cpp:-1: error: undefined reference toglutInitWindowSize' . . . C:\Users\FGHASSEMIT\open1\open1.cpp:-1: error: undefined reference to
_imp__glBegin'
C:\Users\FGHASSEMIT\open1\open1.cpp:-1: error: undefined reference to_imp__glVertex2f' C:\Users\FGHASSEMIT\open1\open1.cpp:-1: error: undefined reference to
_imp__glEnd'
C:\Users\FGHASSEMIT\open1\open1.cpp:-1: error: undefined reference to `_imp__glFlush'
:-1: error: collect2: ld returned 1 exit status -
I agree with ludde. You are trying to use glut to reproduce functionality that is already in Qt. Some glut functions can still make sense to use within Qt (ie for drawing basic geometric shapes such as a sphere).
Take a look at my repository to see a few very simple OpenGL apps that use Qt rather than glut for the windowing functionality. Just use svn to checkout:
@
https://svn.theharmers.co.uk/svn/codes/public/opengl/trunk/
@cd into one of the directories e.g. 06-solar-system then run:
@
qmake
make
@