Results 1 to 9 of 9

Thread: Linking Error (New to GLUT)

  1. #1
    Junior Member Newbie
    Join Date
    Jan 2001
    Location
    Liverpool
    Posts
    6

    Linking Error (New to GLUT)

    Could anyone tell me what the problem is with the following code, I have just installed Borland C++ v5 and installed the GLUT libraries but I get this error : -

    Info :Linking C:\Projects\test.exe
    Error: Error: 'C:\BC5\LIB\GLUT32.LIB' contains invalid OMF record, type 0x21

    The program I have used is from the red OpenGL programming Guide by Mason Woo. Any help would be appreciated.

    #include<windows.h>
    #include<gl\glut.h>
    #include<stdio.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("Square");
    init();
    glutDisplayFunc(display);
    glutMainLoop();
    return 0;
    }

  2. #2
    Senior Member Regular Contributor
    Join Date
    Jul 2000
    Location
    Arlon, Belgium
    Posts
    477

    Re: Linking Error (New to GLUT)

    Don't include <windows.h> or try to have a new .lib file.

  3. #3
    Junior Member Newbie
    Join Date
    Jan 2001
    Location
    Liverpool
    Posts
    6

    Re: Linking Error (New to GLUT)

    I have had a new version of the .lib file sent to me from someone who has tried it and it works on their machine and removed the windows.h but still no joy.

  4. #4
    Senior Member OpenGL Pro
    Join Date
    Oct 2000
    Location
    Fargo, ND
    Posts
    1,753

    Re: Linking Error (New to GLUT)

    Well, it appears to be a linker error not a compiler error so it's probably something with your library. Are you sure the library you were sent is compatible with Borland? VC++ and Borland use different formats for their libraries.

    [This message has been edited by Deiussum (edited 02-17-2001).]
    Deiussum
    Software Engineer and OpenGL enthusiast

  5. #5
    Senior Member Regular Contributor
    Join Date
    May 2001
    Location
    London UK
    Posts
    195

    Re: Linking Error (New to GLUT)

    Yes, the most likely explanation is that the glut32.lib is for msvc coff2omf should be able to convert it. If you are planning to use glut in c++ programs do you also need a modified header. Borland has problems with the exit stuff.

    A modified header and libraries is available among other places at: http://sites.netscape.net/ptrpck/borland.htm

  6. #6
    Junior Member Newbie
    Join Date
    Jan 2001
    Location
    Liverpool
    Posts
    6

    Re: Linking Error (New to GLUT)

    Getting there, the error has gone with the libraries but I am getting the exit problem you mentioned even after downloading the new header file for it. Does anyone have a copy they can mail me ?

    Thanks,
    Brian

  7. #7
    Senior Member Regular Contributor
    Join Date
    May 2001
    Location
    London UK
    Posts
    195

    Re: Linking Error (New to GLUT)

    You can try to define GLUT_DISABLE_ATEXIT_HACK before including glut.h, check the header for the correct name. Strange that the header did not allow C++ but perhaps is it some difference between Borland compilers.

    An alternative could be to download a new header, here is one example: http://www.gnt.net/~heiman/
    I think this a little different version of GLUT so I am not sure if you also must update glut32.lib

  8. #8
    Junior Member Newbie
    Join Date
    Jan 2001
    Location
    Liverpool
    Posts
    6

    Re: Linking Error (New to GLUT)

    The Saga Continues.....

    I updated again and the EXIT problem is gone but now it compiles and pops up a a dialog box with
    "You have accidentally used the dummy version of OwlMain."

    I do not understand this at all Any pointers ???

  9. #9
    Senior Member Regular Contributor
    Join Date
    May 2001
    Location
    London UK
    Posts
    195

    Re: Linking Error (New to GLUT)

    GLUT is doing some hacks with the main/WinMain functions and can be difficult to combine with other libraries. If you are including any OWL headers so try to remove them. Or perhaps is it about how the program is linked?

    The easy solution is to have one C file with the GLUT stuff and use C++ in the other source files. Another option is of course to download the free compiler...

Similar Threads

  1. Linking Error with GLUT
    By Caglow in forum OpenGL: General
    Replies: 7
    Last Post: 09-08-2009, 12:05 PM
  2. linking error
    By in forum OpenGL: Basic Coding
    Replies: 3
    Last Post: 09-28-2002, 05:54 PM
  3. Linking error
    By yang22 in forum OpenGL: Basic Coding
    Replies: 2
    Last Post: 08-15-2002, 12:33 PM
  4. linking error!!!
    By joey in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 11-15-2001, 08:57 PM
  5. linking error
    By imported_Markus_ in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 10-26-2000, 04:18 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Proudly hosted by Digital Ocean