Menu

Linker error. And I *have* read the FAQ ;-)

Christian
2004-11-05
2012-09-26
  • Christian

    Christian - 2004-11-05

    I'm unsing Dev-Cpp 4.9.9.0 with Windows 2000.
    When I'm trying to compile an application with GLUT written in C, compiliation of the objects works fine, but I get plenty of linker errors (log and error messages included at the end of this message).

    What I have done to solve the issue:

    • rebooted Windows ;-)
    • searched this forum for related topics, found a lot of hints about including the libraries with "-l<lib>" but none helped
    • uninstalled and reinstalled Dev-CPP 4.9.9.0
    • uninstalled 4.9.9.0 and reinstalled Dev-CPP 4.9.8.2
    • uninstalled 4.9.8.2 and reinstalled Dev-CPP 4.9.9.0
    • installed MinGW 3.2.3 from the MinGW homepage, and replaced all paths in Dev-Cpp to use the 3.2.3 binaries + libs + includes
    • moved project path to c:\uebung1 (was a path with spaces before)
    • asked a friend to compile my code with Dev-Cpp on his machine resulting in the same error

    I'm really stuck right now and would appreciate any help.

    Christian

    The compiler log lines look like follows:

    ---<snip>-------------------------------------------------------------
    gcc.exe -c cg1_ex1.c -o cg1_ex1.o -I"C:/Dev-Cpp/include"
    gcc.exe -c glutcallbacks.c -o glutcallbacks.o -I"C:/Dev-Cpp/include"
    gcc.exe -c robot.c -o robot.o -I"C:/Dev-Cpp/include"
    gcc.exe -c scenegraph.c -o scenegraph.o -I"C:/Dev-Cpp/include"
    gcc.exe cg1_ex1.o glutcallbacks.o robot.o scenegraph.o -o "uebung1.exe" -L"C:/Dev-Cpp/lib" -lglut32 -lopengl32
    cg1_ex1.o(.text+0x1c):cg1_ex1.c: undefined reference to __glutInitWithExit' cg1_ex1.o(.text+0x37):cg1_ex1.c: undefined reference to__glutCreateWindowWithExit'
    cg1_ex1.o(.text+0x52):cg1_ex1.c: undefined reference to __glutCreateMenuWithExit' cg1_ex1.o(.text+0xab):cg1_ex1.c: undefined reference toglutInitDisplayMode'
    cg1_ex1.o(.text+0xbf):cg1_ex1.c: undefined reference to glutInitWindowSize' cg1_ex1.o(.text+0xd3):cg1_ex1.c: undefined reference toglutInitWindowPosition'
    cg1_ex1.o(.text+0xf3):cg1_ex1.c: undefined reference to glutMainLoop' glutcallbacks.o(.text+0x1c):glutcallbacks.c: undefined reference to__glutInitWithExit'
    glutcallbacks.o(.text+0x37):glutcallbacks.c: undefined reference to __glutCreateWindowWithExit' glutcallbacks.o(.text+0x52):glutcallbacks.c: undefined reference to__glutCreateMenuWithExit'
    glutcallbacks.o(.text+0x33d):glutcallbacks.c: undefined reference to _imp__glMaterialfv' glutcallbacks.o(.text+0x35a):glutcallbacks.c: undefined reference to_imp__glMaterialfv'

    glutcallbacks.o(.text+0x377):glutcallbacks.c: undefined reference to _imp__glMaterialfv' glutcallbacks.o(.text+0x394):glutcallbacks.c: undefined reference to_imp__glLightfv'
    glutcallbacks.o(.text+0x3a9):glutcallbacks.c: undefined reference to `_imp__glLightModelfv'

    glutcallbacks.o(.text+0x3b7):glutcallbacks.c: undefined reference to _imp__glEnable' glutcallbacks.o(.text+0x3c5):glutcallbacks.c: undefined reference to_imp__glEnable'
    glutcallbacks.o(.text+0x3d3):glutcallbacks.c: undefined reference to _imp__glShadeModel' glutcallbacks.o(.text+0x3fd):glutcallbacks.c: undefined reference to_imp__glClearColor'
    glutcallbacks.o(.text+0x40b):glutcallbacks.c: undefined reference to _imp__glClear' glutcallbacks.o(.text+0x419):glutcallbacks.c: undefined reference to_imp__glDepthFunc'
    glutcallbacks.o(.text+0x427):glutcallbacks.c: undefined reference to _imp__glEnable' glutcallbacks.o(.text+0x435):glutcallbacks.c: undefined reference to_imp__glEnable'
    glutcallbacks.o(.text+0x443):glutcallbacks.c: undefined reference to _imp__glMatrixMode' glutcallbacks.o(.text+0x44a):glutcallbacks.c: undefined reference to_imp__glLoadIdentity'
    glutcallbacks.o(.text+0x470):glutcallbacks.c: undefined reference to _imp__gluPerspective' glutcallbacks.o(.text+0x47e):glutcallbacks.c: undefined reference to_imp__glMatrixMode'
    glutcallbacks.o(.text+0x485):glutcallbacks.c: undefined reference to _imp__glLoadIdentity' glutcallbacks.o(.text+0x52e):glutcallbacks.c: undefined reference to_imp__glClear'
    glutcallbacks.o(.text+0x53c):glutcallbacks.c: undefined reference to `_imp__glMatrixMode'

    glutcallbacks.o(.text+0x543):glutcallbacks.c: undefined reference to _imp__glLoadIdentity' glutcallbacks.o(.text+0x583):glutcallbacks.c: undefined reference to_imp__gluLookAt'
    glutcallbacks.o(.text+0x596):glutcallbacks.c: undefined reference to glutSwapBuffers' glutcallbacks.o(.text+0x5df):glutcallbacks.c: undefined reference to_imp__glViewport'
    glutcallbacks.o(.text+0x609):glutcallbacks.c: undefined reference to _imp__glClearColor' glutcallbacks.o(.text+0x617):glutcallbacks.c: undefined reference to_imp__glClear'
    glutcallbacks.o(.text+0x625):glutcallbacks.c: undefined reference to _imp__glMatrixMode' glutcallbacks.o(.text+0x62c):glutcallbacks.c: undefined reference to_imp__glLoadIdentity'
    glutcallbacks.o(.text+0x653):glutcallbacks.c: undefined reference to _imp__gluPerspective' glutcallbacks.o(.text+0x661):glutcallbacks.c: undefined reference to_imp__glMatrixMode'
    glutcallbacks.o(.text+0x668):glutcallbacks.c: undefined reference to _imp__glLoadIdentity' glutcallbacks.o(.text+0x922):glutcallbacks.c: undefined reference toglutDisplayFunc'
    glutcallbacks.o(.text+0x92e):glutcallbacks.c: undefined reference to glutKeyboardFunc' glutcallbacks.o(.text+0x93a):glutcallbacks.c: undefined reference toglutReshapeFunc'
    glutcallbacks.o(.text+0x946):glutcallbacks.c: undefined reference to glutMotionFunc' glutcallbacks.o(.text+0x952):glutcallbacks.c: undefined reference toglutMouseFunc'
    glutcallbacks.o(.text+0x972):glutcallbacks.c: undefined reference to glutAddMenuEntry' glutcallbacks.o(.text+0x986):glutcallbacks.c: undefined reference toglutAddMenuEntry'
    glutcallbacks.o(.text+0x992):glutcallbacks.c: undefined reference to glutAttachMenu' scenegraph.o(.text+0x1c):scenegraph.c: undefined reference to__glutInitWithExit'
    scenegraph.o(.text+0x37):scenegraph.c: undefined reference to __glutCreateWindowWithExit' scenegraph.o(.text+0x52):scenegraph.c: undefined reference to__glutCreateMenuWithExit'

    scenegraph.o(.text+0x8c):scenegraph.c: undefined reference to _imp__glMatrixMode' scenegraph.o(.text+0x93):scenegraph.c: undefined reference to_imp__glPushMatrix'
    scenegraph.o(.text+0xb7):scenegraph.c: undefined reference to _imp__glScalef' scenegraph.o(.text+0xc3):scenegraph.c: undefined reference toglutSolidCube'
    scenegraph.o(.text+0xc8):scenegraph.c: undefined reference to _imp__glPopMatrix' scenegraph.o(.text+0xde):scenegraph.c: undefined reference to_imp__glDisable'
    scenegraph.o(.text+0xec):scenegraph.c: undefined reference to _imp__glBegin' scenegraph.o(.text+0xf3):scenegraph.c: undefined reference to_imp__glEnd'
    scenegraph.o(.text+0x101):scenegraph.c: undefined reference to `_imp__glEnable'
    ---</snip>-------------------------------------------------------------

    This is the Makefile:

    ---<snip>-------------------------------------------------------------

    Project: uebung1

    Makefile created by Dev-C++ 4.9.9.0

    CPP = g++.exe
    CC = gcc.exe
    WINDRES = windres.exe
    RES =
    OBJ = cg1_ex1.o glutcallbacks.o robot.o scenegraph.o $(RES)
    LINKOBJ = cg1_ex1.o glutcallbacks.o robot.o scenegraph.o $(RES)
    LIBS = -L"C:/Dev-Cpp/lib" -lglut32 -lopengl32
    INCS = -I"C:/Dev-Cpp/include"
    CXXINCS = -I"C:/Dev-Cpp/include/c++/3.3.1" -I"C:/Dev-Cpp/include/c++/3.3.1/mingw32" -I"C:/Dev-Cpp/include/c++/3.3.1/backward" -I"C:/Dev-Cpp/include"
    BIN = uebung1.exe
    CXXFLAGS = $(CXXINCS)
    CFLAGS = $(INCS)

    .PHONY: all all-before all-after clean clean-custom

    all: all-before uebung1.exe all-after

    clean: clean-custom
    rm -f $(OBJ) $(BIN)

    $(BIN): $(OBJ)
    $(CC) $(LINKOBJ) -o "uebung1.exe" $(LIBS)

    cg1_ex1.o: cg1_ex1.c
    $(CC) -c cg1_ex1.c -o cg1_ex1.o $(CFLAGS)

    glutcallbacks.o: glutcallbacks.c
    $(CC) -c glutcallbacks.c -o glutcallbacks.o $(CFLAGS)

    robot.o: robot.c
    $(CC) -c robot.c -o robot.o $(CFLAGS)

    scenegraph.o: scenegraph.c
    $(CC) -c scenegraph.c -o scenegraph.o $(CFLAGS)
    ---</snip>-------------------------------------------------------------

     
    • Christian

      Christian - 2004-11-05

      I forgot to say that I've also

      • reset the binary + libs + includes to the Dev-Cpp includes
      • did a "make clean"
      • tried to compile it from command line, without success

      My friend who helped my told me, he could successfully compile the program using gcc from CygWin, but I don't know the version he used.

      Christian

       
    • Nobody/Anonymous

      Try changing the order of your libs.

      gcc is sensitive to the order in which things are linked. I often have this problem when compiling fltk programs.

      LIBS = -L"C:/Dev-Cpp/lib" -lglut32 -lopengl32

      Suggestion might be:

      LIBS = -lglut32 -lopengl32 -L"C:/Dev-Cpp/lib"

      rr

       
      • Christian

        Christian - 2004-11-05

        I have already tried some different orderings from the command line, but it didn't help :-(

        Christian

         
    • Wayne Keen

      Wayne Keen - 2004-11-05

      Where did you get GLUT from, and what did you do with the components you downloaded? Step by step please. Header files, library files and dll files.

      Your linker errors suggest to me that your glut's dll file is not in the right place.

      Wayne

       
      • Christian

        Christian - 2004-11-05

        I got GLUT from this source:
        http://www.xmission.com/~nate/glut.html

        I took the package "glut-3.7.6-bin.zip" and copied:
        glut32.dll --> C:\WINNT\System32
        glut32.lib --> C:\Dev-Cpp\lib
        glut.h --> C:\Dev-Cpp\include\GL

        After I read your message, I downloaded GLUT from the OpenGL homepage:
        http://www.opengl.org/resources/libraries/glut/glut_downloads.html

        I downloaded "glutdlls37beta.zip" and copied:
        glut.dll --> C:\WINNT\System32
        glut32.dll --> C:\WINNT\System32
        glut.lib --> C:\Dev-Cpp\lib
        glut32.lib --> C:\Dev-Cpp\lib
        glut.h --> C:\Dev-Cpp\include\GL

        But this did not help, I still get the same linking errors.

        I'm not sure, but even if the DLL was in the wrong place, linking should still be no problem, shouldn't it? I thought the DLL is loaded at runtime, not at link time...?

        If you like to test my project yourself, you can get it here:
        http://www.dgm.informatik.tu-darmstadt.de/courses/cg1/ex/cg1_ex1.zip

        Nevertheless, thanks for your help!

        Christian

         
    • Wayne Keen

      Wayne Keen - 2004-11-05

      It looks like the static libraries linked, but the dynamic library was not located - hence my question above.

      Wayne

       
    • Christian

      Christian - 2004-11-05

      Finally I got it to link with Cygwin's gcc v3.3.3. I installed Cygwin with some additional packages and changed the binary path for Dev-Cpp to C:\Cygwin{usr\,}bin. But then I got compiler errors because of some missing typedefs in file glu.h. So I removed any path from the Dev-Cpp library and include path -- and my program compiled and linked fine.

      I don't know what kind of difference there is in both gcc versions, but I guess Cygwin's gcc does not use the static libs in C:\Dev-Cpp\libs. This seems quite strange to me.

      Here is the compiler log:
      ------<snip>-------------------------------------------------------------
      rm -f cg1_ex1.o glutcallbacks.o robot.o scenegraph.o uebung1.exe
      gcc.exe -c cg1_ex1.c -o cg1_ex1.o
      gcc.exe -c glutcallbacks.c -o glutcallbacks.o
      gcc.exe -c robot.c -o robot.o
      gcc.exe -c scenegraph.c -o scenegraph.o
      gcc.exe cg1_ex1.o glutcallbacks.o robot.o scenegraph.o -o "uebung1.exe" -lopengl32 -lglut32 -lglu32
      Ausfhrung beendet
      Kompilierung erfolgreich
      ------</snip>-------------------------------------------------------------

      Note that the additional switch -lglu32 is indeed necessary, but I already tried it with the gcc version coming with Dev-Cpp, without success.

      Regards,
      Christian

       
      • Christian

        Christian - 2004-11-06

        So I guess nobody has a clean solution for that? Where could I get a GLUT version that works with the Dev-Cpp libraries?

        Christian

         
        • Wayne Keen

          Wayne Keen - 2004-11-07

          The version I refer to in the "Getting Started" thread works fine for me.

          Wayne

           
    • Nobody/Anonymous

      Christian,

      I have read your post cause I have got the same problem when trying to compile a simpler glut application using Dev-C++. I'm really stuck with this :-( My friends reported the same type of problem. Some of them have even managed to compile their code in Microsoft Visual C++ getting better results.

      The problem is that I WANT to compile my code in Dev-C++! It's a good compiler and I'm too lazy to change my programmer habits so often ^_^

      Sorry...

      Eduardo Rebellis

       
    • Ian Walker

      Ian Walker - 2004-11-07

      You might want to try OpenGLUT (http://openglut.sf.net) which has a DevPak on their SF download page, although I've never tried it.

      The Nate Robins port of the Mark Kilgard GLUT is not actively maintained, so is probably no longer the best.

      I'll give it a go later when I get my copy of Dev working again.

      Cheers,

      Ian

       

Log in to post a comment.

MongoDB Logo MongoDB