Advertisement

I get so many errors compiling the first lesson

Started by July 29, 2004 11:40 PM
3 comments, last by Drevay 20 years, 4 months ago
I think they all start out from near the top, it seems like the errors are coming from the boolean declarations??? line 01: #include <windows.h> line 02: #include <gl/gl.h> line 03: #include <gl/glu.h> line 04: #include <gl/glaux.h> line 05: line 06: HGLRC hRC = NULL; // Permanent Rendering Context line 07: HDC hDC = NULL; // Private GDI Device Context line 08: HWND hWnd = NULL; // Holds our Window Handle line 09: HINSTANCE hInstance; // Holds the Instance of the Application line 10: line 11: bool keys[256]; line 12: bool active = TRUE; line 13: bool fullscreen = TRUE; I'm using Dev-C++ 4.0, but I also installed a trial copy of Visual C++ 6.0 from a cd in one of my textbooks... Similiar errors. Neither one of them like the booleans. Here's a list of the first 10 or so errors (of 29 -- most related back to the boolean stuff...) window.c:11: parse error before `keys' window.c:11: warning: data definition has no type or storage class window.c:12: parse error before `active' window.c:12: warning: data definition has no type or storage class window.c:13: parse error before `fullscreen' window.c:13: warning: data definition has no type or storage class window.c:101: parse error before `CreateGLWindow' window.c:101: parse error before `bool' window.c: In function `CreateGLWindow': window.c:110: `width' undeclared (first use in this function) window.c:110: (Each undeclared identifier is reported only once for each function it appears in.) window.c:112: `height' undeclared (first use in this function) window.c:114: `fullscreenflag' undeclared (first use in this function) window.c:141: `bits' undeclared (first use in this function) Anyways, any help/advice would be nice. I spent quite a while typing out that code all the while being excited about starting the next lessons... Now I'm hung up on compiling an empty window, its a bit frustrating. Thanks
bool is a C++ type and doesn't exist in C. Since you are using a .C extension for your source file, the compiler is assuming your are using C. Change the file extension to .CC or .CPP or change the compiler options to force C++ mode.
Advertisement
And don't forget to include glaux.lib, OpenGL.lib, and Glu32.lib in the project settings! That's tripped me up a few times before :)

(I think those are the names...)
I do real things with imaginary numbers
Yea I had my libraries linked properly after reading lots of other threads on dev-c++ which pointed that out. My problem was what Dave said, I was compiling as a C project and C doesn't have a bool as a data type. I recompiled as C++ and got my total errors down to 1 after some dumb errors on my part. I posted another thread, and after my final dumb error, my window works perfect!

Thanks for the quick replies, I'm now on my way to learning OpenGL thanks to NeHe and this forum!

A while ago I bought the book "Beginning OpenGL Game Programming" by Astle Hawkins but these tutorials helped me better. I'm looking forward to reading that book after I do 4-5 tutorials on NeHe's site, and I recommend others to do that too (not necessarily for that book, but for any OpenGL book). WRITE CODE first, and read every one of NeHe's comments, understand whats going on, than learn the internals of OpenGL, thats my opinion.

Anyways, I appreciate the help but now I'm off to tutorial #2!
GCC will compile this fine with glaux.h, as long as you have glaux.h in the GL directory, and you use BOOL everywhere bool is used.

Plus, find the bits [ctrl+f] (you really should download the latest Dev-C++ then run the updater, it's a hell of a lot better), and replace that with the number 32.

GCC throws some odd errors around, but I think if you do the above it should work (works fine for me).

EDIT - Btw, when I say GCC I mean using the .c extension on your files - but don't forget to link the proper libs.

The libs you should link are:

-lmingw
-lopengl32
-lglu32
-mwindows

That's about it.
_________________Politics is the ability to foretell what is going to happen tomorrow, next week, next month and next year. And to have the ability afterwards to explain why it didn't happen. -- Winston ChurchillGDNet-0.2 - rate users the easy way with this nifty Firefox extension. Updated with new features.

This topic is closed to new replies.

Advertisement