PDA

View Full Version : Newbie Compiler Error Problem



PhilMag
09-01-2002, 11:46 AM
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

tinak
09-01-2002, 12:21 PM
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

nexusone
09-01-2002, 02:25 PM
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>

Pa3PyX
09-01-2002, 11:27 PM
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...

PhilMag
09-02-2002, 01:44 AM
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

nexusone
09-02-2002, 05:57 AM
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

The_V|k|ng
09-02-2002, 07:51 AM
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

PhilMag
09-02-2002, 09:44 AM
Thanks, you guys seem to know everything http://www.opengl.org/discussion_boards/ubb/smile.gif

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

The_V|k|ng
09-02-2002, 09:53 PM
> Thanks, you guys seem to know everything

Hey, we all started where you are... http://www.opengl.org/discussion_boards/ubb/wink.gif And I had just about the same problems, you know... http://www.opengl.org/discussion_boards/ubb/smile.gif

> 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 (http://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

PhilMag
09-04-2002, 05:52 AM
Thanks for all being so helpful,
I'm finally up and running.

Cheers,

Phil