help

Discussion in 'C++' started by kaltter, Mar 14, 2005.

  1. kaltter

    kaltter Guest

    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?
    kaltter, Mar 14, 2005
    #1
    1. Advertising

  2. 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
    Victor Bazarov, Mar 14, 2005
    #2
    1. Advertising

  3. 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.
    Victor Bazarov, Mar 14, 2005
    #3
  4. kaltter

    Sivert Berg Guest

    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.
    Sivert Berg, Mar 14, 2005
    #4
  5. kaltter

    kaltter Guest

    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
    kaltter, Mar 14, 2005
    #5
  6. 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.
    Victor Bazarov, Mar 14, 2005
    #6
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?dHJlbGxvdzQyMg==?=

    HELP! HELP! HELP! Opening Web Application Project Error

    =?Utf-8?B?dHJlbGxvdzQyMg==?=, Feb 20, 2004, in forum: ASP .Net
    Replies:
    0
    Views:
    742
    =?Utf-8?B?dHJlbGxvdzQyMg==?=
    Feb 20, 2004
  2. Harvey
    Replies:
    0
    Views:
    667
    Harvey
    Jul 16, 2004
  3. Harvey
    Replies:
    1
    Views:
    818
    Daniel
    Jul 16, 2004
  4. =?Utf-8?B?S2ltb24gSWZhbnRpZGlz?=

    HELP - HELP - HELP

    =?Utf-8?B?S2ltb24gSWZhbnRpZGlz?=, Mar 9, 2006, in forum: ASP .Net
    Replies:
    4
    Views:
    662
    Eliyahu Goldin
    Mar 9, 2006
  5. Buster

    Help, Help, Help

    Buster, Oct 4, 2003, in forum: Java
    Replies:
    3
    Views:
    461
    Saager
    Oct 30, 2003
Loading...

Share This Page