C OpenGL Compiler Error?

This is a discussion on C OpenGL Compiler Error? within the C Programming forums, part of the General Programming Boards category; Hey! Recently I've been trying to compile some code with OpenGL with Dev-C++ 4. Dev-C++ can compile C, so I ...

  1. #1
    Registered User
    Join Date
    Jun 2006
    Posts
    47

    C OpenGL Compiler Error?

    Hey!

    Recently I've been trying to compile some code with OpenGL with Dev-C++ 4. Dev-C++ can compile C, so I don't get it. I'm using GLUT.h, so that's the thing that is making it all messed up. When I compile anything, even using the test source code they give you, I get something like this:

    Code:
    C:\DOCUME~1\MATTMI~1\LOCALS~1\Temp\ccOcbaaa.o(.text+0x40e):spacem~1.c: undefined reference to `glutGet'
    C:\DOCUME~1\MATTMI~1\LOCALS~1\Temp\ccOcbaaa.o(.text+0x436):spacem~1.c: undefined reference to `_imp__glBegin'
    C:\DOCUME~1\MATTMI~1\LOCALS~1\Temp\ccOcbaaa.o(.text+0x450):spacem~1.c: undefined reference to `_imp__glColor3f'
    C:\DOCUME~1\MATTMI~1\LOCALS~1\Temp\ccOcbaaa.o(.text+0x4d3):spacem~1.c: undefined reference to `_imp__glVertex2f'
    C:\DOCUME~1\MATTMI~1\LOCALS~1\Temp\ccOcbaaa.o(.text+0x4e6):spacem~1.c: undefined reference to `_imp__glEnd'
    C:\DOCUME~1\MATTMI~1\LOCALS~1\Temp\ccOcbaaa.o(.text+0x539):spacem~1.c: undefined reference to `_imp__glPushMatrix'
    C:\DOCUME~1\MATTMI~1\LOCALS~1\Temp\ccOcbaaa.o(.text+0x55e):spacem~1.c: undefined reference to `_imp__glTranslatef'
    C:\DOCUME~1\MATTMI~1\LOCALS~1\Temp\ccOcbaaa.o(.text+0x57b):spacem~1.c: undefined reference to `_imp__glRotatef'
    C:\DOCUME~1\MATTMI~1\LOCALS~1\Temp\ccOcbaaa.o(.text+0x59f):spacem~1.c: undefined reference to `_imp__glColor3f'
    C:\DOCUME~1\MATTMI~1\LOCALS~1\Temp\ccOcbaaa.o(.text+0x5af):spacem~1.c: undefined reference to `_imp__glBegin'
    C:\DOCUME~1\MATTMI~1\LOCALS~1\Temp\ccOcbaaa.o(.text+0x5d5):spacem~1.c: undefined reference to `_imp__glVertex2f'
    C:\DOCUME~1\MATTMI~1\LOCALS~1\Temp\ccOcbaaa.o(.text+0x5f1):spacem~1.c: undefined reference to `_imp__glVertex2f'
    C:\DOCUME~1\MATTMI~1\LOCALS~1\Temp\ccOcbaaa.o(.text+0x617):spacem~1.c: undefined reference to `_imp__glVertex2f'
    C:\DOCUME~1\MATTMI~1\LOCALS~1\Temp\ccOcbaaa.o(.text+0x622):spacem~1.c: undefined reference to `_imp__glEnd'
    C:\DOCUME~1\MATTMI~1\LOCALS~1\Temp\ccOcbaaa.o(.text+0x639):spacem~1.c: undefined reference to `_imp__glColor3f'
    C:\DOCUME~1\MATTMI~1\LOCALS~1\Temp\ccOcbaaa.o(.text+0x649):spacem~1.c: undefined reference to `_imp__glBegin'
    C:\DOCUME~1\MATTMI~1\LOCALS~1\Temp\ccOcbaaa.o(.text+0x665):spacem~1.c: undefined reference to `_imp__glVertex2f'
    C:\DOCUME~1\MATTMI~1\LOCALS~1\Temp\ccOcbaaa.o(.text+0x68b):spacem~1.c: undefined reference to `_imp__glVertex2f'
    C:\DOCUME~1\MATTMI~1\LOCALS~1\Temp\ccOcbaaa.o(.text+0x6a7):spacem~1.c: undefined reference to `_imp__glVertex2f'
    C:\DOCUME~1\MATTMI~1\LOCALS~1\Temp\ccOcbaaa.o(.text+0x6c6):spacem~1.c: undefined reference to `_imp__glVertex2f'
    C:\DOCUME~1\MATTMI~1\LOCALS~1\Temp\ccOcbaaa.o(.text+0x6e2):spacem~1.c: undefined reference to `_imp__glVertex2f'
    C:\DOCUME~1\MATTMI~1\LOCALS~1\Temp\ccOcbaaa.o(.text+0x6ed):spacem~1.c: undefined reference to `_imp__glEnd'
    C:\DOCUME~1\MATTMI~1\LOCALS~1\Temp\ccOcbaaa.o(.text+0x722):spacem~1.c: undefined reference to `_imp__glColor3f'
    C:\DOCUME~1\MATTMI~1\LOCALS~1\Temp\ccOcbaaa.o(.text+0x732):spacem~1.c: undefined reference to `_imp__glBegin'
    C:\DOCUME~1\MATTMI~1\LOCALS~1\Temp\ccOcbaaa.o(.text+0x7e0):spacem~1.c: undefined reference to `_imp__glVertex2f'
    C:\DOCUME~1\MATTMI~1\LOCALS~1\Temp\ccOcbaaa.o(.text+0x7fa):spacem~1.c: undefined reference to `_imp__glEnd'
    C:\DOCUME~1\MATTMI~1\LOCALS~1\Temp\ccOcbaaa.o(.text+0x802):spacem~1.c: undefined reference to `_imp__glPopMatrix'
    C:\DOCUME~1\MATTMI~1\LOCALS~1\Temp\ccOcbaaa.o(.text+0x821):spacem~1.c: undefined reference to `_imp__glClear'
    C:\DOCUME~1\MATTMI~1\LOCALS~1\Temp\ccOcbaaa.o(.text+0x847):spacem~1.c: undefined reference to `glutSwapBuffers'
    C:\DOCUME~1\MATTMI~1\LOCALS~1\Temp\ccOcbaaa.o(.text+0x887):spacem~1.c: undefined reference to `glutGet'
    C:\DOCUME~1\MATTMI~1\LOCALS~1\Temp\ccOcbaaa.o(.text+0xac3):spacem~1.c: undefined reference to `glutPostWindowRedisplay'
    C:\DOCUME~1\MATTMI~1\LOCALS~1\Temp\ccOcbaaa.o(.text+0xaea):spacem~1.c: undefined reference to `glutIdleFunc'
    C:\DOCUME~1\MATTMI~1\LOCALS~1\Temp\ccOcbaaa.o(.text+0xaf9):spacem~1.c: undefined reference to `glutIdleFunc'
    C:\DOCUME~1\MATTMI~1\LOCALS~1\Temp\ccOcbaaa.o(.text+0xcf5):spacem~1.c: undefined reference to `glutGet'
    C:\DOCUME~1\MATTMI~1\LOCALS~1\Temp\ccOcbaaa.o(.text+0xd47):spacem~1.c: undefined reference to `glutSetCursor'
    C:\DOCUME~1\MATTMI~1\LOCALS~1\Temp\ccOcbaaa.o(.text+0xd8d):spacem~1.c: undefined reference to `glutGameModeString'
    C:\DOCUME~1\MATTMI~1\LOCALS~1\Temp\ccOcbaaa.o(.text+0xd95):spacem~1.c: undefined reference to `glutEnterGameMode'
    C:\DOCUME~1\MATTMI~1\LOCALS~1\Temp\ccOcbaaa.o(.text+0xdac):spacem~1.c: undefined reference to `glutGameModeString'
    C:\DOCUME~1\MATTMI~1\LOCALS~1\Temp\ccOcbaaa.o(.text+0xdb4):spacem~1.c: undefined reference to `glutEnterGameMode'
    C:\DOCUME~1\MATTMI~1\LOCALS~1\Temp\ccOcbaaa.o(.text+0xdd7):spacem~1.c: undefined reference to `glutLeaveGameMode'
    C:\DOCUME~1\MATTMI~1\LOCALS~1\Temp\ccOcbaaa.o(.text+0xe09):spacem~1.c: undefined reference to `glutIdleFunc'
    C:\DOCUME~1\MATTMI~1\LOCALS~1\Temp\ccOcbaaa.o(.text+0xe1b):spacem~1.c: undefined reference to `glutIdleFunc'
    C:\DOCUME~1\MATTMI~1\LOCALS~1\Temp\ccOcbaaa.o(.text+0xee6):spacem~1.c: undefined reference to `_imp__glBlendFunc'
    C:\DOCUME~1\MATTMI~1\LOCALS~1\Temp\ccOcbaaa.o(.text+0xef9):spacem~1.c: undefined reference to `_imp__glEnable'
    C:\DOCUME~1\MATTMI~1\LOCALS~1\Temp\ccOcbaaa.o(.text+0xf0c):spacem~1.c: undefined reference to `_imp__glEnable'
    C:\DOCUME~1\MATTMI~1\LOCALS~1\Temp\ccOcbaaa.o(.text+0xf1f):spacem~1.c: undefined reference to `_imp__glEnable'
    C:\DOCUME~1\MATTMI~1\LOCALS~1\Temp\ccOcbaaa.o(.text+0xf3a):spacem~1.c: undefined reference to `_imp__glDisable'
    C:\DOCUME~1\MATTMI~1\LOCALS~1\Temp\ccOcbaaa.o(.text+0xf4d):spacem~1.c: undefined reference to `_imp__glDisable'
    C:\DOCUME~1\MATTMI~1\LOCALS~1\Temp\ccOcbaaa.o(.text+0xf60):spacem~1.c: undefined reference to `_imp__glDisable'
    C:\DOCUME~1\MATTMI~1\LOCALS~1\Temp\ccOcbaaa.o(.text+0xf83):spacem~1.c: undefined reference to `glutGet'
    C:\DOCUME~1\MATTMI~1\LOCALS~1\Temp\ccOcbaaa.o(.text+0xfa6):spacem~1.c: undefined reference to `glutGet'
    C:\DOCUME~1\MATTMI~1\LOCALS~1\Temp\ccOcbaaa.o(.text+0xfc9):spacem~1.c: undefined reference to `glutGet'
    C:\DOCUME~1\MATTMI~1\LOCALS~1\Temp\ccOcbaaa.o(.text+0x1057):spacem~1.c: undefined reference to `glutGet'
    C:\DOCUME~1\MATTMI~1\LOCALS~1\Temp\ccOcbaaa.o(.text+0x10f9):spacem~1.c: undefined reference to `glutGet'
    C:\DOCUME~1\MATTMI~1\LOCALS~1\Temp\ccOcbaaa.o(.text+0x114c):spacem~1.c: more undefined references to `glutGet' follow
    C:\DOCUME~1\MATTMI~1\LOCALS~1\Temp\ccOcbaaa.o(.text+0x11a1):spacem~1.c: undefined reference to `glutIgnoreKeyRepeat'
    C:\DOCUME~1\MATTMI~1\LOCALS~1\Temp\ccOcbaaa.o(.text+0x11b1):spacem~1.c: undefined reference to `glutDisplayFunc'
    C:\DOCUME~1\MATTMI~1\LOCALS~1\Temp\ccOcbaaa.o(.text+0x11c1):spacem~1.c: undefined reference to `glutVisibilityFunc'
    C:\DOCUME~1\MATTMI~1\LOCALS~1\Temp\ccOcbaaa.o(.text+0x11d1):spacem~1.c: undefined reference to `glutKeyboardFunc'
    C:\DOCUME~1\MATTMI~1\LOCALS~1\Temp\ccOcbaaa.o(.text+0x11e1):spacem~1.c: undefined reference to `glutKeyboardUpFunc'
    C:\DOCUME~1\MATTMI~1\LOCALS~1\Temp\ccOcbaaa.o(.text+0x11f1):spacem~1.c: undefined reference to `glutSpecialFunc'
    C:\DOCUME~1\MATTMI~1\LOCALS~1\Temp\ccOcbaaa.o(.text+0x1201):spacem~1.c: undefined reference to `glutSpecialUpFunc'
    C:\DOCUME~1\MATTMI~1\LOCALS~1\Temp\ccOcbaaa.o(.text+0x1213):spacem~1.c: undefined reference to `glutJoystickFunc'
    C:\DOCUME~1\MATTMI~1\LOCALS~1\Temp\ccOcbaaa.o(.text+0x1224):spacem~1.c: undefined reference to `_imp__glMatrixMode'
    C:\DOCUME~1\MATTMI~1\LOCALS~1\Temp\ccOcbaaa.o(.text+0x122f):spacem~1.c: undefined reference to `_imp__glLoadIdentity'
    C:\DOCUME~1\MATTMI~1\LOCALS~1\Temp\ccOcbaaa.o(.text+0x1267):spacem~1.c: undefined reference to `_imp__glOrtho'
    C:\DOCUME~1\MATTMI~1\LOCALS~1\Temp\ccOcbaaa.o(.text+0x127a):spacem~1.c: undefined reference to `_imp__glMatrixMode'
    C:\DOCUME~1\MATTMI~1\LOCALS~1\Temp\ccOcbaaa.o(.text+0x1294):spacem~1.c: undefined reference to `_imp__glPointSize'
    C:\DOCUME~1\MATTMI~1\LOCALS~1\Temp\ccOcbaaa.o(.text+0x129e):spacem~1.c: undefined reference to `glutGetWindow'
    C:\DOCUME~1\MATTMI~1\LOCALS~1\Temp\ccOcbaaa.o(.text+0x12db):spacem~1.c: undefined reference to `glutInit'
    C:\DOCUME~1\MATTMI~1\LOCALS~1\Temp\ccOcbaaa.o(.text+0x12e8):spacem~1.c: undefined reference to `glutInitDisplayMode'
    C:\DOCUME~1\MATTMI~1\LOCALS~1\Temp\ccOcbaaa.o(.text+0x131d):spacem~1.c: undefined reference to `glutGameModeString'
    C:\DOCUME~1\MATTMI~1\LOCALS~1\Temp\ccOcbaaa.o(.text+0x1325):spacem~1.c: undefined reference to `glutEnterGameMode'
    C:\DOCUME~1\MATTMI~1\LOCALS~1\Temp\ccOcbaaa.o(.text+0x1339):spacem~1.c: undefined reference to `glutCreateWindow'
    C:\DOCUME~1\MATTMI~1\LOCALS~1\Temp\ccOcbaaa.o(.text+0x134d):spacem~1.c: undefined reference to `glutMainLoop'
    Can anyone tell me what's wrong? Thanks! I've tried everything, and nothing works!

    ~Matt3000

  2. #2
    Gawking at stupidity
    Join Date
    Jul 2004
    Location
    Oregon, USA
    Posts
    3,159
    Looks like you're not including the library.

    Go to: Project -> Project Options, Parameter tab, click the Add Library or Object button.
    If you understand what you're doing, you're not learning anything.

  3. #3
    Registered User
    Join Date
    Jun 2006
    Posts
    47

    Still Problems!

    Okay. Now I did that, and it won't let me run the program! It compiles 100% with no errors, but the "RUN" button is inactive, and where the file is in C:\, there is no .exe!

    Here is the exact code I use!

    Code:
    /* Copyright (c) Mark J. Kilgard, 1994. */
    
    /* This program is freely distributable without licensing fees 
       and is provided without guarantee or warrantee expressed or 
       implied. This program is -not- in the public domain. */
    
    #include <stdio.h>
    #include <stdlib.h>
    #include <GL/glut.h>
    
    int ch = -2;
    void *font = GLUT_STROKE_ROMAN;
    
    void
    tick(void)
    {
      ch += 1;
      if (ch > 180) {
        if (font == GLUT_STROKE_MONO_ROMAN) {
          printf("PASS: test4\n");
          exit(0);
        }
        ch = -2;
        font = GLUT_STROKE_MONO_ROMAN;
      }
      glutPostRedisplay();
    }
    
    void
    display(void)
    {
      glutIdleFunc(tick);
      glClear(GL_COLOR_BUFFER_BIT);
      glPushMatrix();
      glutStrokeCharacter(font, ch);
      glPopMatrix();
      glutSwapBuffers();
    }
    
    int
    main(int argc, char **argv)
    {
      glutInit(&argc, argv);
      glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB);
      glutInitWindowSize(200, 200);
      glutCreateWindow("Test stroke fonts");
      if (glutGet(GLUT_WINDOW_COLORMAP_SIZE) != 0) {
        printf("FAIL: bad RGBA colormap size\n");
        exit(1);
      }
      glMatrixMode(GL_PROJECTION);
      glLoadIdentity();
      gluOrtho2D(-50, 150, -50, 150);
      glClearColor(0.0, 0.0, 0.0, 1.0);
      glColor3f(1.0, 1.0, 1.0);
      glutDisplayFunc(display);
      glutMainLoop();
      return 0;             /* ANSI C requires main to return int. */
    }
    I JUST FOUND OUT! I HAVE LIBRARY FILE PROBLEMS! HELP ME!
    Last edited by Matt3000; 06-27-2006 at 06:44 PM.

  4. #4
    Gawking at stupidity
    Join Date
    Jul 2004
    Location
    Oregon, USA
    Posts
    3,159
    If the Run button is inactive that usually means the program is already running. Check Task Manager and make sure it's not listed under Processes. If it is, kill it.

    The .exe file for projects usually goes in C:\Dev-Cpp (or wherever you installed it) and the .c files go in the Templates subfolder.
    If you understand what you're doing, you're not learning anything.

  5. #5
    Registered User
    Join Date
    Jun 2006
    Posts
    47

    Still Probs

    Hey. Thanks for the help so far, but I still need more!

    It's the LIB files. In the project options section, I've put this:

    Code:
    -lopengl32 -lglu32 -lglut32
    But I get all this back!

    Code:
    c:\space_magus.o(.text+0x65):space_magus.c: undefined reference to `glutPostRedisplay'
    c:\space_magus.o(.text+0x7c):space_magus.c: undefined reference to `glutIdleFunc'
    c:\space_magus.o(.text+0x8d):space_magus.c: undefined reference to `_imp__glClear'
    c:\space_magus.o(.text+0x98):space_magus.c: undefined reference to `_imp__glPushMatrix'
    c:\space_magus.o(.text+0xae):space_magus.c: undefined reference to `glutStrokeCharacter'
    c:\space_magus.o(.text+0xb7):space_magus.c: undefined reference to `_imp__glPopMatrix'
    c:\space_magus.o(.text+0xbe):space_magus.c: undefined reference to `glutSwapBuffers'
    c:\space_magus.o(.text+0x120):space_magus.c: undefined reference to `glutInit'
    c:\space_magus.o(.text+0x12d):space_magus.c: undefined reference to `glutInitDisplayMode'
    c:\space_magus.o(.text+0x142):space_magus.c: undefined reference to `glutInitWindowSize'
    c:\space_magus.o(.text+0x152):space_magus.c: undefined reference to `glutCreateWindow'
    c:\space_magus.o(.text+0x15f):space_magus.c: undefined reference to `glutGet'
    c:\space_magus.o(.text+0x19a):space_magus.c: undefined reference to `_imp__glMatrixMode'
    c:\space_magus.o(.text+0x1a5):space_magus.c: undefined reference to `_imp__glLoadIdentity'
    c:\space_magus.o(.text+0x1dc):space_magus.c: undefined reference to `gluOrtho2D'
    c:\space_magus.o(.text+0x1f0):space_magus.c: undefined reference to `_imp__glClearColor'
    c:\space_magus.o(.text+0x20d):space_magus.c: undefined reference to `_imp__glColor3f'
    c:\space_magus.o(.text+0x21f):space_magus.c: undefined reference to `glutDisplayFunc'
    c:\space_magus.o(.text+0x227):space_magus.c: undefined reference to `glutMainLoop'
    Last edited by Matt3000; 06-27-2006 at 08:48 PM. Reason: New Info

  6. #6
    Registered User
    Join Date
    Apr 2004
    Posts
    42
    I use -lglut32

    If you have just glut, use -lglut

    Is that what you wanted?
    Last edited by Link_26; 06-27-2006 at 08:48 PM.

  7. #7
    Registered User
    Join Date
    Jun 2006
    Posts
    47
    Nope, still get the same errors. :-(

    But I hear something on the internet about a DevPack GLUT? I just downloaded it from an OpenGL site. Is there a certain Dev-C++ version I should use?
    Last edited by Matt3000; 06-27-2006 at 08:52 PM.

  8. #8
    Registered User
    Join Date
    Apr 2004
    Posts
    42
    In your source file, you didn't include the opengl header. Without it, i get a bunch of errors too, but with it, your code compiles.

    #include <gl/gl.h>

    That work?

  9. #9
    Gawking at stupidity
    Join Date
    Jul 2004
    Location
    Oregon, USA
    Posts
    3,159
    Quote Originally Posted by Matt3000
    Is there a certain Dev-C++ version I should use?
    I use 4.9.9.2, but I haven't done any OpenGL programming in Windows. Sorry I can't be of any more help.
    If you understand what you're doing, you're not learning anything.

  10. #10
    Registered User
    Join Date
    Jun 2006
    Posts
    47
    No, that gives me more errors. I think those includes are already in the Glut.h file. I think there is a DevPak I'm supposed to download.

  11. #11
    Registered User
    Join Date
    Jul 2006
    Posts
    2

    Question

    Same problem. I have downloaded the OpenGL devpacks through the tools->check for updates/packages
    I still get whacked errors like this:

    A3.o(.text+0xc0e): In function `Z4idlev': C:/.../A3.c:280: undefined reference to `glutGet'

    A3.o(.text+0xdb0): C:/.../A3.c:314: undefined reference to `glutPostRedisplay'

    A3.o(.text+0x1002): In function `Z7displayv': C:/.../A3.c:368: undefined reference to `glutSwapBuffers'

    I have been trying to figure this out for weeks...
    I originally wrote the code in linux, actually, but that shouldnt matter with c++, and i have gotten regular glu programs to work, just not glut or glui ones

  12. #12
    Frequently Quite Prolix dwks's Avatar
    Join Date
    Apr 2005
    Location
    Canada
    Posts
    8,046
    Those are linker errors. You're not linking with what you should be.

    Make sure those library files exist, and see if there are any others you need to add.
    dwk

    Seek and ye shall find. quaere et invenies.

    "Simplicity does not precede complexity, but follows it." -- Alan Perlis
    "Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
    "The only real mistake is the one from which we learn nothing." -- John Powell


    Other boards: DaniWeb, TPS
    Unofficial Wiki FAQ: cpwiki.sf.net

    My website: http://dwks.theprogrammingsite.com/
    Projects: codeform, xuni, atlantis, nort, etc.

  13. #13
    Registered User
    Join Date
    Jul 2006
    Posts
    2

    Lightbulb

    Quote Originally Posted by Matt3000
    It's the LIB files. In the project options section, I've put this:

    Code:
    -lopengl32 -lglu32 -lglut32

    Well i got it to work. The truth is that the above libraries must be linked in the REVERSE ORDER... contradictory to EVERY SOURCE i've found on the matter... maybe it's just this version of DEV-C++... whacked

    in your project options->parameters set it to this:

    Code:
    -lglut32 -lglu32 -lopengl32 -lwinmm -lgdi32
    i am not certain what winmm and gdi32 are, but they appear to be necessary for windows.

    hooray!
    Last edited by Scorpius; 07-07-2006 at 04:51 PM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Getting an error with OpenGL: collect2: ld returned 1 exit status
    By Lorgon Jortle in forum C++ Programming
    Replies: 6
    Last Post: 05-08-2009, 08:18 PM
  2. Making C DLL using MSVC++ 2005
    By chico1st in forum C Programming
    Replies: 26
    Last Post: 05-28-2008, 01:17 PM
  3. load gif into program
    By willc0de4food in forum Windows Programming
    Replies: 14
    Last Post: 01-11-2006, 09:43 AM
  4. Dikumud
    By maxorator in forum C++ Programming
    Replies: 1
    Last Post: 10-01-2005, 06:39 AM
  5. Linking error
    By DockyD in forum C++ Programming
    Replies: 10
    Last Post: 01-20-2003, 04:27 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21