Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 10 of 10

Thread: Compiling Errors, why?

  1. #1
    Junior Member Newbie
    Join Date
    Feb 2004
    Location
    MI
    Posts
    5

    Compiling Errors, why?

    I get these errors compiling opengl source code in Linux:
    /tmp/ccXUFm6i.o(.text+0xf): In function `display':
    : undefined reference to `glClear'
    /tmp/ccXUFm6i.o(.text+0x29): In function `display':
    : undefined reference to `glColor3f'
    /tmp/ccXUFm6i.o(.text+0x36): In function `display':
    : undefined reference to `glBegin'
    /tmp/ccXUFm6i.o(.text+0x4d): In function `display':
    : undefined reference to `glVertex3f'
    /tmp/ccXUFm6i.o(.text+0x64): In function `display':
    : undefined reference to `glVertex3f'
    /tmp/ccXUFm6i.o(.text+0x7b): In function `display':
    : undefined reference to `glVertex3f'
    /tmp/ccXUFm6i.o(.text+0x92): In function `display':
    : undefined reference to `glVertex3f'
    /tmp/ccXUFm6i.o(.text+0x9a): In function `display':
    : undefined reference to `glEnd'
    /tmp/ccXUFm6i.o(.text+0x9f): In function `display':
    : undefined reference to `glFlush'
    /tmp/ccXUFm6i.o(.text+0xb4): In function `init':
    : undefined reference to `glClearColor'
    /tmp/ccXUFm6i.o(.text+0xc4): In function `init':
    : undefined reference to `glMatrixMode'
    /tmp/ccXUFm6i.o(.text+0xcc): In function `init':
    : undefined reference to `glLoadIdentity'
    /tmp/ccXUFm6i.o(.text+0xf5): In function `init':
    : undefined reference to `glOrtho'
    /tmp/ccXUFm6i.o(.text+0x119): In function `main':
    : undefined reference to `glutInit'
    /tmp/ccXUFm6i.o(.text+0x126): In function `main':
    : undefined reference to `glutInitDisplayMode'
    /tmp/ccXUFm6i.o(.text+0x13b): In function `main':
    : undefined reference to `glutInitWindowSize'
    /tmp/ccXUFm6i.o(.text+0x14a): In function `main':
    : undefined reference to `glutInitWindowPosition'
    /tmp/ccXUFm6i.o(.text+0x15a): In function `main':
    : undefined reference to `glutCreateWindow'
    /tmp/ccXUFm6i.o(.text+0x16f): In function `main':
    : undefined reference to `glutDisplayFunc'
    /tmp/ccXUFm6i.o(.text+0x177): In function `main':
    : undefined reference to `glutMainLoop'
    collect2: ld returned 1 exit status

    from the very firsr opengl example form the redbook. here is the source anyways:

    #include <GL/glut.h>
    #include <GL/gl.h>

    void display(void)
    {
    glClear (GL_COLOR_BUFFER_BIT);
    glColor3f (1.0, 1.0, 1.0);
    glBegin (GL_POLYGON);
    glVertex3f (0.25, 0.25, 0.0);
    glVertex3f (0.75, 0.25, 0.0);
    glVertex3f (0.75, 0.75, 0.0);
    glVertex3f (0.25, 0.75, 0.0);
    glEnd();
    glFlush ();
    }

    void init(void)
    {
    glClearColor (0.0, 0.0, 0.0, 0.0);
    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();
    glOrtho(0.0, 1.0, 0.0, 1.0, -1.0, 1.0);
    }

    int main(int argc, char** argv)
    {
    glutInit(&argc, argv);
    glutInitDisplayMode (GLUT_SINGLE | GLUT_RGB);
    glutInitWindowSize(250, 250);
    glutInitWindowPosition(100, 100);
    glutCreateWindow("hello");
    init();
    glutDisplayFunc(display);
    glutMainLoop();
    return 0;
    }

    also all other code does the same thing. anyone may know why?

  2. #2
    Member Regular Contributor
    Join Date
    Oct 2001
    Location
    Princeton, NJ
    Posts
    386

    Re: Compiling Errors, why?

    you need to link with the libraries, this is unique to your compiler so check the documentation

  3. #3
    Senior Member OpenGL Guru
    Join Date
    Jun 2000
    Location
    Gastonia, NC, USA
    Posts
    2,070

    Re: Compiling Errors, why?

    How are you calling the compiler, from a console window or a IDE like k-develope?

    You need to tell the linker to include the openGL librarys, should look something like this: -lGL -lGLU -lglut

    You also need to make sure you have installed the glut runtime library's and developement librarys.
    Redhat has them as a RPM installation file.



    [This message has been edited by nexusone (edited 02-18-2004).]

  4. #4
    Junior Member Newbie
    Join Date
    Feb 2004
    Location
    MI
    Posts
    5

    Re: Compiling Errors, why?

    thank you so much for help, ill look into it, I also got Slackware 9.1 which has the opengl libraries, because I found the header files.

  5. #5
    Junior Member Newbie
    Join Date
    Feb 2004
    Location
    MI
    Posts
    5

    Re: Compiling Errors, why?

    still doesnt work, also all other programs that use libraries get the same error. still have no clue, compiling works, only linking doesnt.

  6. #6
    Member Regular Contributor
    Join Date
    Oct 2001
    Location
    Princeton, NJ
    Posts
    386

    Re: Compiling Errors, why?

    how are you compiling
    if you are using and IDE which is it?
    if you are using a command line what is the exact line you type in?

  7. #7
    Junior Member Newbie
    Join Date
    Feb 2004
    Location
    MI
    Posts
    5

    Re: Compiling Errors, why?

    im compiling using a terminal, and gcc like this:
    gcc filename.c
    if i compile using anjuta it compiles correctly so there is no syntax errors in the file, but when it tries to build it fails with the errors.
    but i usully do it in terminal.
    also today i was writting a source code which used the curses.h include file and that game me a bunch of same errors.
    thank you....

  8. #8
    Intern Contributor
    Join Date
    Jul 2003
    Location
    va beach
    Posts
    63

    Re: Compiling Errors, why?

    Have you made doubly sure that you've install and linked them under gcc? I have found gcc to be an excellent compiler, but it's as tempermental as a HollyWood Starlet.

  9. #9
    Super Moderator OpenGL Lord
    Join Date
    Dec 2003
    Location
    Grenoble - France
    Posts
    5,575

    Re: Compiling Errors, why?

    im compiling using a terminal, and gcc like this:
    gcc filename.c
    Hehe, maybe it is not enough. As everybody here told you, try to add the libraries :

    gcc filename.c -lGL -lGLU -lglut

    If you can find the actual name of the lib, eg. libGL.so, just cut out the leading 'lib' and trailing '.so'
    I do not remember for curses, try something like -lcurses

    If it still does not work, maybe the lib*.so are located at a non-standard place, you can add the dir with a command switch: -L/usr/mydir . Find the lib*.so with a simple 'locate filename'.

    Good luck !

    [This message has been edited by ZbuffeR (edited 02-22-2004).]

  10. #10
    Junior Member Newbie
    Join Date
    Feb 2004
    Location
    MI
    Posts
    5

    Re: Compiling Errors, why?

    Hehe, yeah. I had to use the -L and -l to include the libraries....Thank you so much fopr help you guys.

    Len

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •