Menu

undefined reference to __glutInitWithExit@12

BiT
2008-02-07
2012-09-26
  • BiT

    BiT - 2008-02-07

    For Johnny (johnny1988) and your welcome
    since the thread you posted to has been
    there since 2004-03-07...unless you want
    people to yell at you for not paying attention!!


    I believe I am telling about well known but not solved problem:
    when compiling there are comes errors:
    [Linker error] undefined reference to `__glutInitWithExit@12' and etc.

    (1)My version of Dev-Cpp is 4.9.9.2

    (2)The code is:

    include <windows.h>

    include <gl/glut.h>

    include <stdlib.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;
    }

    (3) Full log is:
    Compiler: Default compiler
    Building Makefile: "E:\temp\opengl\Makefile.win"
    Executing make...
    make.exe -f "E:\temp\opengl\Makefile.win" all
    g++.exe main.o -o "opengl.exe" -L"lib" -lopengl32 -lglut32 -mwindows -lglut32 -lopengl32 -lglu32

    main.o(.text+0x1c):main.cpp: undefined reference to __glutInitWithExit@12' main.o(.text+0x3d):main.cpp: undefined reference toglutCreateWindowWithExit@8'
    main.o(.text+0x5d):main.cpp: undefined reference to `
    glutCreateMenuWithExit@8'
    collect2: ld returned 1 exit status

    make.exe: *** [opengl.exe] Error 1

    Execution terminated

     
    • cpns

      cpns - 2008-02-07

      This symbols do not exist in libglut32.a (a scan of the file, and a Google search will tell you that). My guess as a result of Googling is that you are using a book that uses these functions and that they are provided perhaps as part of the source code associated with the book.

      BTW you have attempted to link the same libraries multiple times, and modified the standard Dev-C++ lib path. I wonder why?

      Clifford

       

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.