Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 10 of 10

Thread: Newbie Compiler Error Problem

  1. #1
    Junior Member Newbie
    Join Date
    Sep 2002
    Location
    United Kingdom
    Posts
    7

    Newbie Compiler Error Problem

    I wonder if someone can help me....
    I am trying to learn about OpenGL to prepare for my computer graphics course at uni next year. Today I dled the Borland C++ compiler for win98 and followed the instructions to set it up (putting gl.h, glu.h, glut.h in include/gl dir, glu32.lib, opengl32.lib, glut32.lib in lib dir and glu32.dll, opengl32.dll and glut32.dll in windows/system). I made myself a bcc32.cfg file:

    -I"c:\Progra~1\Borland\Bcc55\include"
    -L"c:\Progra~1\Borland\Bcc55\lib"
    -W

    and an ilink32.cfg file:

    -L"c:\Progra~1\Borland\Bcc55\lib"

    and put them in the bin dir.
    I also set the PATH variable correctly.
    To test that I had set everything up properly I copied a simple program from a book:

    #include <windows.h>
    #include <gl/gl.h>
    #include <gl/glut.h>
    //<<<<<<<<<<<<<<<<<<<<<<myInit>>>>>>>>>>>>>>>
    void myInit(void)
    {
    glClearColor(1.0,1.0,1.0,0.0); //set white bg colour
    glColor3f(0.0f, 0.0f, 0.0f); //set the drawing color
    glPointSize(4.0); //a dot is 4x4 pixels
    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();
    gluOrtho2D(0.0, 640.0, 0.0, 480.0);
    }
    //<<<<<<<<<<<<<<<<<<<<<myDisplay>>>>>>>>>>>>>
    void myDisplay(void)
    {
    glClear(GL_COLOR_BUFFER_BIT); //clear the screen
    glBegin(GL_POINTS);
    glVertex2i(100, 50); //draw 3 points
    glVertex2i(100, 130);
    glVertex2i(150, 130);
    glEnd();
    glFlush(); //send all output to display
    }
    //<<<<<<<<<<<<<<<<<<<<<main>>>>>>>>>>>>>>>>>>
    void main(int argc, char** argv)
    {
    glutInit(&argc, argv); //init the toolkit
    glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB); //set display mode
    glutInitWindowSize(640,480); //set window size
    glutInitWindowPosition(100, 150); //set window position
    glutCreateWindow("my first attempt"); //open screen window
    glutDisplayFunc(myDisplay); //register redraw fn
    myInit();
    glutMainLoop(); //go into a perpetual loop
    }

    I saved this as DrawDot.cpp.
    When I attempted to compile the program in dos (bcc32 DotDraw.cpp) I got the following error "Error E2337 c:\Progra~1\Borland\Bcc5\include\gl/glut.h 146: Only one of a set of overloaded functions can be "C".
    I am sorry if this is a really stupid question but I know nothing about setting up compilers or OpenGL except for what I have learnt today. Please could someone tell me what I am doing wrong so I can get on and practise some proper OpenGl coding.

    Phil

  2. #2

    Re: Newbie Compiler Error Problem

    Hmm, this seems to be due to both gl.h and glut.h having the same block of code as follows:

    #ifdef __cplusplus
    extern "C" {
    #endif

    Now, MSVC doesn't seem to have a problem with this which I assume is because they are both testing the same define value in my copies of these include files. Perhaps a check with your copies of these files will highlight a slightly different define test in one of these files causing the compiler to kick up a fuss.

    Tina
    Learning OpenGL while working on sourceforge projects:
    https://sourceforge.net/projects/simulant/ and
    https://sourceforge.net/projects/projectnova/

  3. #3
    Senior Member OpenGL Guru
    Join Date
    Jun 2000
    Location
    Gastonia, NC, USA
    Posts
    2,070

    Re: Newbie Compiler Error Problem

    You error maybe due to the fact that glut.h, has refernce in it glu.h windows.h.

    Try removing: windows.h and glu.h.
    Use only: #include<GL/glut.h>

  4. #4

    Re: Newbie Compiler Error Problem

    Yea, I remember the pain of setting up GLUT to work with Borland's compiler... AFAIR, the problem is, the author tries to avoid including windows.h to prevent namespace pollution, but that doesn't work with Borland's compiler. Define the following thing (put it at the very start of your program):

    #define WIN32_LEAN_AND_MEAN

    or undefine it (#undef), I don't remember already, or comment it out in GLUT code, and it should include "windows.h" and compile properly...

  5. #5
    Junior Member Newbie
    Join Date
    Sep 2002
    Location
    United Kingdom
    Posts
    7

    Re: Newbie Compiler Error Problem

    Thanks for all your help.
    Adding #define WIN32_LEAN_AND_MEAN at the start of the program got rid of the error but caused a new one!
    Now when I try and comile the program it gets a bit further (a DotDraw.obj file is created) but I get the error:

    'c:\program files\borland\bcc55\lib\glut32.lib' contains invalid OMF record, type 0x21 (possibly COFF)

    What does this mean?
    I spose if everything worked first time life would be boring!

    Phil

  6. #6
    Senior Member OpenGL Guru
    Join Date
    Jun 2000
    Location
    Gastonia, NC, USA
    Posts
    2,070

    Re: Newbie Compiler Error Problem

    Do you have a glut.lib made for Borland?
    The problem maybe you have a MSVC++ lib, I think that Borland has a utility that converts a MSVC lib to a borland lib file

    Originally posted by PhilMag:
    Thanks for all your help.
    Adding #define WIN32_LEAN_AND_MEAN at the start of the program got rid of the error but caused a new one!
    Now when I try and comile the program it gets a bit further (a DotDraw.obj file is created) but I get the error:

    'c:\program files\borland\bcc55\lib\glut32.lib' contains invalid OMF record, type 0x21 (possibly COFF)

    What does this mean?
    I spose if everything worked first time life would be boring!

    Phil

  7. #7
    Junior Member Newbie
    Join Date
    Feb 2002
    Posts
    23

    Re: Newbie Compiler Error Problem

    You need to create your own .lib-files via implib, which comes with the Borland compiler.
    The syntax is:

    implib [MyNewLibFile] [MySourceDLL]

    So all you need to do is create your opengl32.lib, glu32.lib and glu32.lib as follows:

    implib c:\program files\borland\bcc55\lib\glut32.lib c:\windows\system\glut32.dll

    Same with glu32.dll and opengl32.dll.

    I also recommend downloading a decent text editor like TextPad (www.textpad.com) that you can use as a customizable GUI for almost anything. I've been using Borland and TextPad for a year now and I am really happy with them.

    Regards,
    The_V|k|ng

  8. #8
    Junior Member Newbie
    Join Date
    Sep 2002
    Location
    United Kingdom
    Posts
    7

    Re: Newbie Compiler Error Problem

    Thanks, you guys seem to know everything

    I'm sorry to be such a newbie but every problem that gets sorted seems to create another one which i have no idea how to fix.

    I have created the library files using implib and now there is no error but instead I get the message:

    Fatal: unable to open file 'winmm.lib'

    I have checked and the file is in c:\program files\borland\bcc55\lib\PSDK there is also a winmm.dll file in c:\windows\system

    What does this mean?

    I apologise for my continuing incompetance, I didn't realise setting up a compiler was this hard!

    Phil

  9. #9
    Junior Member Newbie
    Join Date
    Feb 2002
    Posts
    23

    Re: Newbie Compiler Error Problem

    > Thanks, you guys seem to know everything

    Hey, we all started where you are... And I had just about the same problems, you know...

    > I'm sorry to be such a newbie but every problem that gets sorted seems to create another one which i have no idea how to fix.

    Jesus Christ, there's no need to be emarassed or something. After all, we all have been newbies once, as I said.

    Looking at your problem, it means that the linker is unable to open the winmm.lib. Since the file does exist, the logical consequence is that the linker does not look at that place. So, you can either (since you have -L"c:\Progra~1\Borland\Bcc55\lib" specified in your ilink32.cfg) copy the file into the \lib directory or add -L"c:\program files\borland\bcc55\lib\PSDK" to your ilink32.cfg.
    You should really familliarize yourself with the compiler, as it is quite important for understanding error messages or adding ressources. There are a couple of help files well hidden somewhere at www.borland.com which are really worth getting. These are not only the BC55 commandline tools help files, but also some of the Borland C++ Builder help. And, most important, the windows help file, ms????, I dunno the real name any more.
    Good luck with OpenGL!

    The_V|k|ng

  10. #10
    Junior Member Newbie
    Join Date
    Sep 2002
    Location
    United Kingdom
    Posts
    7

    Re: Newbie Compiler Error Problem

    Thanks for all being so helpful,
    I'm finally up and running.

    Cheers,

    Phil

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •