Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > help

Reply
 
 
kaltter
Guest
Posts: n/a
 
      03-14-2005
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?

 
Reply With Quote
 
 
 
 
Victor Bazarov
Guest
Posts: n/a
 
      03-14-2005
kaltter wrote:
> 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
 
Reply With Quote
 
 
 
 
Victor Bazarov
Guest
Posts: n/a
 
      03-14-2005
Sivert Berg wrote:
> [...]
> 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.
 
Reply With Quote
 
Sivert Berg
Guest
Posts: n/a
 
      03-14-2005
kaltter wrote:
> 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.
 
Reply With Quote
 
kaltter
Guest
Posts: n/a
 
      03-14-2005
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

 
Reply With Quote
 
Victor Bazarov
Guest
Posts: n/a
 
      03-14-2005
kaltter wrote:
> 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.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Help Help Help Pentax S5i Help needed (Please) The Martian Digital Photography 14 06-20-2008 07:56 AM
HELP - HELP - HELP =?Utf-8?B?S2ltb24gSWZhbnRpZGlz?= ASP .Net 4 03-09-2006 12:46 PM
HELP WANTED HELP WANTED HELP WANTED Harvey ASP .Net 1 07-16-2004 01:12 PM
HELP WANTED HELP WANTED HELP WANTED Harvey ASP .Net 0 07-16-2004 10:00 AM
HELP! HELP! HELP! Opening Web Application Project Error =?Utf-8?B?dHJlbGxvdzQyMg==?= ASP .Net 0 02-20-2004 05:16 PM



Advertisments