Thread: Dev-C++ and glut

  1. #1
    Registered User
    Join Date
    Apr 2011
    Posts
    37

    Unhappy Dev-C++ and glut

    Hello, I have installed my include files and .dlls (I believe), but I am still receiving these errors when I try to compile:

    Compiler: Default compiler
    Executing gcc.exe...
    gcc.exe "C:\Users\drewtoby\Desktop\cube.c" -o "C:\Users\drewtoby\Desktop\cube.exe" -ansi -traditional-cpp -I"C:\Dev-Cpp\include" -L"C:\Dev-Cpp\lib"
    C:\Users\drewtoby\AppData\Local\Temp/ccMJaaaa.o(.text+0x1c):cube.c: undefined reference to `__glutInitWithExit@12'
    C:\Users\drewtoby\AppData\Local\Temp/ccMJaaaa.o(.text+0x3c):cube.c: undefined reference to `__glutCreateWindowWithExit@8'
    C:\Users\drewtoby\AppData\Local\Temp/ccMJaaaa.o(.text+0x5c):cube.c: undefined reference to `__glutCreateMenuWithExit@8'
    C:\Users\drewtoby\AppData\Local\Temp/ccMJaaaa.o(.text+0x86):cube.c: undefined reference to `_imp__glBegin@4'
    C:\Users\drewtoby\AppData\Local\Temp/ccMJaaaa.o(.text+0xa4):cube.c: undefined reference to `_imp__glNormal3fv@4'
    C:\Users\drewtoby\AppData\Local\Temp/ccMJaaaa.o(.text+0xcb):cube.c: undefined reference to `_imp__glVertex3fv@4'
    C:\Users\drewtoby\AppData\Local\Temp/ccMJaaaa.o(.text+0xf2):cube.c: undefined reference to `_imp__glVertex3fv@4'
    C:\Users\drewtoby\AppData\Local\Temp/ccMJaaaa.o(.text+0x119):cube.c: undefined reference to `_imp__glVertex3fv@4'
    C:\Users\drewtoby\AppData\Local\Temp/ccMJaaaa.o(.text+0x140):cube.c: undefined reference to `_imp__glVertex3fv@4'
    C:\Users\drewtoby\AppData\Local\Temp/ccMJaaaa.o(.text+0x14a):cube.c: undefined reference to `_imp__glEnd@0'
    C:\Users\drewtoby\AppData\Local\Temp/ccMJaaaa.o(.text+0x16a):cube.c: undefined reference to `_imp__glClear@4'
    C:\Users\drewtoby\AppData\Local\Temp/ccMJaaaa.o(.text+0x179):cube.c: undefined reference to `glutSwapBuffers@0'
    C:\Users\drewtoby\AppData\Local\Temp/ccMJaaaa.o(.text+0x233):cube.c: undefined reference to `_imp__glLightfv@12'

    C:\Users\drewtoby\AppData\Local\Temp/ccMJaaaa.o(.text+0x254):cube.c: undefined reference to `_imp__glLightfv@12'
    C:\Users\drewtoby\AppData\Local\Temp/ccMJaaaa.o(.text+0x265):cube.c: undefined reference to `_imp__glEnable@4'
    C:\Users\drewtoby\AppData\Local\Temp/ccMJaaaa.o(.text+0x276):cube.c: undefined reference to `_imp__glEnable@4'
    C:\Users\drewtoby\AppData\Local\Temp/ccMJaaaa.o(.text+0x287):cube.c: undefined reference to `_imp__glEnable@4'
    C:\Users\drewtoby\AppData\Local\Temp/ccMJaaaa.o(.text+0x298):cube.c: undefined reference to `_imp__glMatrixMode@4'
    C:\Users\drewtoby\AppData\Local\Temp/ccMJaaaa.o(.text+0x2c1):cube.c: undefined reference to `_imp__gluPerspective@32'
    C:\Users\drewtoby\AppData\Local\Temp/ccMJaaaa.o(.text+0x2d2):cube.c: undefined reference to `_imp__glMatrixMode@4'
    C:\Users\drewtoby\AppData\Local\Temp/ccMJaaaa.o(.text+0x315):cube.c: undefined reference to `_imp__gluLookAt@72'
    C:\Users\drewtoby\AppData\Local\Temp/ccMJaaaa.o(.text+0x339):cube.c: undefined reference to `_imp__glTranslatef@12'
    C:\Users\drewtoby\AppData\Local\Temp/ccMJaaaa.o(.text+0x366):cube.c: undefined reference to `_imp__glRotatef@16'
    C:\Users\drewtoby\AppData\Local\Temp/ccMJaaaa.o(.text+0x393):cube.c: undefined reference to `_imp__glRotatef@16'
    C:\Users\drewtoby\AppData\Local\Temp/ccMJaaaa.o(.text+0x3e5):cube.c: undefined reference to `glutInitDisplayMode@4'
    C:\Users\drewtoby\AppData\Local\Temp/ccMJaaaa.o(.text+0x403):cube.c: undefined reference to `glutDisplayFunc@4'
    C:\Users\drewtoby\AppData\Local\Temp/ccMJaaaa.o(.text+0x410):cube.c: undefined reference to `glutMainLoop@0'
    collect2: ld returned 1 exit status

    Execution terminated


    from code:

    Code:
    /* Copyright (c) Mark J. Kilgard, 1997. */
    
    /* 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. */
    
    /* This program was requested by Patrick Earl; hopefully someone else
       will write the equivalent Direct3D immediate mode program. */
    
    #include <glut.h>
    #include <gl.h>
    #include <glu.h>
    
    GLfloat light_diffuse[] = {1.0, 0.0, 0.0, 1.0};  /* Red diffuse light. */
    GLfloat light_position[] = {1.0, 1.0, 1.0, 0.0};  /* Infinite light location. */
    GLfloat n[6][3] = {  /* Normals for the 6 faces of a cube. */
      {-1.0, 0.0, 0.0}, {0.0, 1.0, 0.0}, {1.0, 0.0, 0.0},
      {0.0, -1.0, 0.0}, {0.0, 0.0, 1.0}, {0.0, 0.0, -1.0} };
    GLint faces[6][4] = {  /* Vertex indices for the 6 faces of a cube. */
      {0, 1, 2, 3}, {3, 2, 6, 7}, {7, 6, 5, 4},
      {4, 5, 1, 0}, {5, 6, 2, 1}, {7, 4, 0, 3} };
    GLfloat v[8][3];  /* Will be filled in with X,Y,Z vertexes. */
    
    void
    drawBox(void)
    {
      int i;
    
      for (i = 0; i < 6; i++) {
        glBegin(GL_QUADS);
        glNormal3fv(&n[i][0]);
        glVertex3fv(&v[faces[i][0]][0]);
        glVertex3fv(&v[faces[i][1]][0]);
        glVertex3fv(&v[faces[i][2]][0]);
        glVertex3fv(&v[faces[i][3]][0]);
        glEnd();
      }
    }
    
    void
    display(void)
    {
      glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
      drawBox();
      glutSwapBuffers();
    }
    
    void
    init(void)
    {
      /* Setup cube vertex data. */
      v[0][0] = v[1][0] = v[2][0] = v[3][0] = -1;
      v[4][0] = v[5][0] = v[6][0] = v[7][0] = 1;
      v[0][1] = v[1][1] = v[4][1] = v[5][1] = -1;
      v[2][1] = v[3][1] = v[6][1] = v[7][1] = 1;
      v[0][2] = v[3][2] = v[4][2] = v[7][2] = 1;
      v[1][2] = v[2][2] = v[5][2] = v[6][2] = -1;
    
      /* Enable a single OpenGL light. */
      glLightfv(GL_LIGHT0, GL_DIFFUSE, light_diffuse);
      glLightfv(GL_LIGHT0, GL_POSITION, light_position);
      glEnable(GL_LIGHT0);
      glEnable(GL_LIGHTING);
    
      /* Use depth buffering for hidden surface elimination. */
      glEnable(GL_DEPTH_TEST);
    
      /* Setup the view of the cube. */
      glMatrixMode(GL_PROJECTION);
      gluPerspective( /* field of view in degree */ 40.0,
        /* aspect ratio */ 1.0,
        /* Z near */ 1.0, /* Z far */ 10.0);
      glMatrixMode(GL_MODELVIEW);
      gluLookAt(0.0, 0.0, 5.0,  /* eye is at (0,0,5) */
        0.0, 0.0, 0.0,      /* center is at (0,0,0) */
        0.0, 1.0, 0.);      /* up is in positive Y direction */
    
      /* Adjust cube position to be asthetic angle. */
      glTranslatef(0.0, 0.0, -1.0);
      glRotatef(60, 1.0, 0.0, 0.0);
      glRotatef(-20, 0.0, 0.0, 1.0);
    }
    
    int
    main(int argc, char **argv)
    {
      glutInit(&argc, argv);
      glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH);
      glutCreateWindow("red 3D lighted cube");
      glutDisplayFunc(display);
      init();
      glutMainLoop();
      return 0;             /* ANSI C requires main to return int. */
    }
    What can I do to get the compiler to recognize the commands?! Thanks!!!!

  2. #2
    Banned
    Join Date
    Aug 2010
    Location
    Ontario Canada
    Posts
    9,547
    And did you list the GLUT libraires for your linker?

    It's not enough to set a path in GCC... you've got to tell it which library files to use, from that path.

  3. #3
    Registered User
    Join Date
    Apr 2011
    Posts
    37
    Nope, thanks! Would I have to do that manually, or through the program? I am new to dev :[ Know of any tutorials?

  4. #4
    Registered User
    Join Date
    Apr 2011
    Posts
    37
    Or could I just do that through including the glut folder under the libaries in the compiler options?

  5. #5
    Registered User ssharish2005's Avatar
    Join Date
    Sep 2005
    Location
    Cambridge, UK
    Posts
    1,732
    Well its quite time consuming to type the whole process of installing GLUT library. But here is a link which explain on how to install GLUT and setup the linker options.
    Dev-C++ & OpenGL
    And also you will need to add an extra path to the GL include. You could do that by clicking on Tools - Compiler Options - Directories tab - and here add a path to the GL include folder. Normally it is C:\Dev-Cpp\include\GL

    ssharish
    Life is like riding a bicycle. To keep your balance you must keep moving - Einstein

  6. #6
    Registered User
    Join Date
    Apr 2011
    Posts
    37
    Thanks!!!

  7. #7
    Registered User
    Join Date
    Apr 2011
    Posts
    37
    I'll work on it!!!

  8. #8
    Registered User claudiu's Avatar
    Join Date
    Feb 2010
    Location
    London, United Kingdom
    Posts
    2,094
    Here's a better advice, drop Dev alltogether, it is obsolete, abandonware and generally crap.
    1. Get rid of gets(). Never ever ever use it again. Replace it with fgets() and use that instead.
    2. Get rid of void main and replace it with int main(void) and return 0 at the end of the function.
    3. Get rid of conio.h and other antiquated DOS crap headers.
    4. Don't cast the return value of malloc, even if you always always always make sure that stdlib.h is included.

  9. #9
    Registered User
    Join Date
    Dec 2007
    Posts
    2,675
    Here's another idea. Before you jump into trying to program with a graphics library, you learn how to program without. You're just setting yourself up for a world of hurt without real solid fundamentals.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. To use GLUT or not?
    By Jake.c in forum Game Programming
    Replies: 14
    Last Post: 08-17-2009, 06:26 PM
  2. Glut
    By Matty_Alan in forum C Programming
    Replies: 7
    Last Post: 07-16-2007, 07:01 AM
  3. GLUT in 16-bit RGB?
    By dxfoo in forum Game Programming
    Replies: 5
    Last Post: 09-14-2006, 08:55 AM
  4. Glut
    By Lurker in forum Game Programming
    Replies: 1
    Last Post: 01-14-2004, 05:27 PM
  5. using GLUT and MS VC++
    By revelation437 in forum C++ Programming
    Replies: 0
    Last Post: 04-01-2003, 04:16 PM