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 4 of 4

Thread: undefined reference to `gluOrtho2D'

  1. #1
    Junior Member Newbie
    Join Date
    Mar 2010
    Posts
    2

    undefined reference to `gluOrtho2D'

    Hi all,
    This is my first program to display a couple of points: what is wrong with it?
    On doing below i get:
    [surabhi@localhost ~]$ cc points.c -lglut
    /tmp/cckmTBn0.o: In function `myinit':
    points.c.text+0x10d): undefined reference to `gluOrtho2D'
    collect2: ld returned 1 exit status

    The program is as below.

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

    void display()
    {
    glClear(GL_COLOR_BUFFER_BIT);
    glColor3f(1.0,1.0,0.0);
    glBegin(GL_POINTS);
    glVertex2f(10.0,10.0);
    glVertex2f(150.0,80.0);
    glVertex2f(100.0,20.0);
    glVertex2f(200.0,100.0);
    glEnd();
    glFlush();
    }

    void myinit()
    {
    glClearColor(0.0,1.0,1.0,1.0);
    glPointSize(10.0);
    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();
    gluOrtho2D(.0,50.0,.0,50.0);
    }

    int main(int argc,char **argv)
    {
    glutInit(&amp;argc,argv);
    glutInitDisplayMode(GLUT_SINGLE|GLUT_RGB);
    glutInitWindowSize(300,200);
    glutInitWindowPosition(0,700);
    glutCreateWindow("points");
    glutDisplayFunc(display);
    myinit();
    glutMainLoop();
    return 0;
    }


    Do i need to reinstall opengl in my system (fedora)? i have tried installing many glut packages, but i still get this output.

  2. #2
    Super Moderator OpenGL Guru dorbie's Avatar
    Join Date
    Jul 2000
    Location
    Bay Area, CA, USA
    Posts
    4,388

    Re: undefined reference to `gluOrtho2D'

    Either include glu.h or try glOrtho and add near and far clip values.

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

    Re: undefined reference to `gluOrtho2D'

    doing yum install freeglut-devel should be enough.

    Then do not forgot to add -lGLU to your linker options too.

  4. #4
    Junior Member Newbie
    Join Date
    Mar 2010
    Posts
    2

    Re: undefined reference to `gluOrtho2D'

    hey guys thanks,adding -lGLU worked!!

Posting Permissions

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