help

K

kaltter

Hi, I'm trying to make an application using opengl i'm using all the
standar functions very similar to some examples i've seen on the
internet, but when compiling some error messages appear saying
something like

undefined reference to 'glClear'
undefined reference to 'glVertex2f'
undefined reference to 'glVertex2f'
undefined reference to 'glVertex2f'
undefined reference to 'glVertex2f'

i've included all the libraries but it just does not work
the trcky part is that i've executed other applications that use these
same functions and they run perfectly, does someone know what can be
causing this?
 
V

Victor Bazarov

kaltter said:
Hi, I'm trying to make an application using opengl i'm using all the
standar functions very similar to some examples i've seen on the
internet, but when compiling some error messages appear saying
something like

undefined reference to 'glClear'
undefined reference to 'glVertex2f'
undefined reference to 'glVertex2f'
undefined reference to 'glVertex2f'
undefined reference to 'glVertex2f'

i've included all the libraries but it just does not work

Are you sure you included all the libraries? And in the right order?
the trcky part is that i've executed other applications that use these
same functions and they run perfectly, does someone know what can be
causing this?

You will have to compare the compilation command lines you used to create
the other applications to the one you're using to create the current one
and see what's different.

More on linking and libraries -- in the newsgroup for your compiler, since
C++ does not really define how those things are done. Since linking and
resolution of symbols from some external libraries is not part of the C++
language specification, your question is off-topic... Sorry!

V
 
V

Victor Bazarov

Sivert said:
[...]
Give us abit more specs. OS? And ofcourse the commandline.

Please consider os-specific newsgroups for that. Command lines
are definitely not part of C++ language.
 
S

Sivert Berg

kaltter said:
Hi, I'm trying to make an application using opengl i'm using all the
standar functions very similar to some examples i've seen on the
internet, but when compiling some error messages appear saying
something like

undefined reference to 'glClear'
undefined reference to 'glVertex2f'
undefined reference to 'glVertex2f'
undefined reference to 'glVertex2f'
undefined reference to 'glVertex2f'

i've included all the libraries but it just does not work
the trcky part is that i've executed other applications that use these
same functions and they run perfectly, does someone know what can be
causing this?

Give us abit more specs. OS? And ofcourse the commandline.
 
K

kaltter

I' using debian linux,
the code is very simple


---------------globject.h------------------------
#ifndef __CLASSGLOBJECT
#define __CLASSGLOBJECT

#include <qgl.h>

class GLObject : public QGLWidget{
public:
GLObject(QWidget * p=0);
~GLObject();
GLuint createDL();
void draw();
};
#endif

---------------globject.cpp-------------------

#include "globject.h"
#include <qpainter.h>

GLObject::GLObject(QWidget * p) : QGLWidget(p){}

GLObject::~GLObject(){}

GLuint GLObject::createDL(){
GLuint index;
index=glGenLists(1);
glNewList(index, GL_COMPILE);
draw();
glEndList();
return index;
}

void GLObject::draw(){
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
//glColor(0.9f, 0.9f, 0.9f);
glBegin(GL_QUADS);
glVertex2f(-100.0f, 0.0f);
glVertex2f(-100.0f, 100.0f);
glVertex2f(0.0f, 100.0f);
glVertex2f(100.0f, -100.0f);
glEnd();
}


----------------------------aplication.cpp-----------------------------------------------
#include <qapplication.h>
#include <qpainter.h>
#include "globject.h"

int main(int argc, char **argv){
QApplication a(argc, argv);
GLObject glObject;
a.setMainWidget(&glObject);
glObject.show();
return a.exec();
}


--------------------------------and these are the error
messages-------------------------------------
compiling using : qmake -project && qmake && make

g++ -c -pipe -Wall -W -O2 -DQT_NO_DEBUG -DQT_SHARED
-DQT_THREAD_SUPPORT -I/usr/share/qt3/mkspecs/default -I. -I.
-I/usr/include/qt3 -o aplication.o aplication.cpp
g++ -c -pipe -Wall -W -O2 -DQT_NO_DEBUG -DQT_SHARED
-DQT_THREAD_SUPPORT -I/usr/share/qt3/mkspecs/default -I. -I.
-I/usr/include/qt3 -o globject.o globject.cpp
g++ -o cg aplication.o globject.o -L/usr/share/qt3/lib
-L/usr/X11R6/lib -lqt-mt -lXext -lX11 -lm
globject.o(.text+0x141): In function `GLObject::createDL()':
: undefined reference to `glGenLists'
globject.o(.text+0x154): In function `GLObject::createDL()':
: undefined reference to `glNewList'
globject.o(.text+0x164): In function `GLObject::createDL()':
: undefined reference to `glEndList'
globject.o(.text+0x1a6): In function `GLObject::draw()':
: undefined reference to `glClear'
globject.o(.text+0x1b2): In function `GLObject::draw()':
: undefined reference to `glBegin'
globject.o(.text+0x1be): In function `GLObject::draw()':
: undefined reference to `glVertex2f'
globject.o(.text+0x1ca): In function `GLObject::draw()':
: undefined reference to `glVertex2f'
globject.o(.text+0x1d6): In function `GLObject::draw()':
: undefined reference to `glVertex2f'
globject.o(.text+0x1e2): In function `GLObject::draw()':
: undefined reference to `glVertex2f'
globject.o(.text+0x1f3): In function `GLObject::draw()':
: undefined reference to `glEnd'
collect2: ld returned 1 exit status
make: *** [cg] Error 1
 
V

Victor Bazarov

kaltter said:
I' using debian linux,

Try comp.os.linux.development.apps next time, please.
g++ -o cg aplication.o globject.o -L/usr/share/qt3/lib
-L/usr/X11R6/lib -lqt-mt -lXext -lX11 -lm

I can't see -lGL here anywhere. Can you? What about other OpenGL libs?

And you're still off-topic.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top