OpenGL problem

Started by
8 comments, last by flucknugget 21 years, 11 months ago
I''m trying to compile an OpenGL program that draws a triangle, and that''s it, and I''m getting this error. c:\code\msvc\opengl test\opengl test.cpp(163) : fatal error C1010: unexpected end of file while looking for precompiled header directive I included , , and . I linked opengl32.lib, glu32.lib, and glaux.lib. Is there anything else I need to do? - f l u c k y p o o - the geek inside
- f l u c k y p o o
Advertisement
If you are using MSVC++ (which I assume you are) you can get rid of the '/Fp' and '/Yc' compiler options by:

Goto (menu)Project->Settings then goto the C++ Tab, and then goto the 'Project Options:' textbox and remove the '/Fp******.pch' and remove '/Yc******.h'

That should fix it. I think those switches create Precompiled headers which may be faster to compile? Im not quite.

Check MSDN Library for more information.(/Fp /Yc) Also, please note that this is my first post of any help so I may be wrong, but, this has been my experience with precompiled headers...

Henry.



[Edit: links]




[edited by - henrym on May 3, 2002 2:33:03 AM]
An easy way to turn off precompiled headers for a single cpp file (in MSVC++) is to go to project->settings.

Then select the cpp file (in the left tree view thingy) you wish to disable precompiled headers for. Click the C/C++ tag, then select precompiled headers from the Catergory drop down box, then finally choose the "Not using precompiled headers" radio box.

Hope this helps.
Turnig off precompiled headers is one option (see the other posts). But precompiled headers are by no means useless, especially when you have a large project: they will reduce your compilation time. The trick is to buid the project, in order for the precompiled header to be generated.

This means:
1. generate a new project
2. Add some code
3. instead of compiling a file build the project

IIRC, you need to do this pnly once, as long as you don''t modify stdafx.h (wich you shouldn''t!)

HTH

Forever trusting who we are
And nothing else matters
- Metallica
Forever trusting who we areAnd nothing else matters - Metallica
Ok, I tried going and removing all the /Fc and /Yc stuff, only there wasn''t any /Yc stuff. So I just removed the /Fc, and that didn''t fix it. Then I told my project to use no precompiled headers, and I got a bunch of Windows errors, I think because it wasn''t using stdafx.h. So I put that back.. and it still doesn''t work. I remember a long time ago, the first time I was trying to get OpenGL to work it just worked fine without chaging any funky compiler options. Are you supposed to have to do this for each project?


- f l u c k y p o o
- the geek inside
- f l u c k y p o o
Have you tried turning off precompiled headers for all the cpp files, except the main one that includes stdafx.h ?

What kind of errors did you get with all your precompiled headers off ?
Well, right now I only have one file since this is just a little opengl test program to try and set the graphics mode and draw a triangle. Here are the errors I get when I disable all the precompiled headers.

c:\code\msvc\opengl test\main.cpp(113) : error C2664: ''RegisterClassA'' : cannot convert parameter 1 from ''struct tagWNDCLASSEXA *'' to ''const struct tagWNDCLASSA *''
Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
c:\code\msvc\opengl test\main.cpp(148) : error C2065: ''glTranslate'' : undeclared identifier
c:\code\msvc\opengl test\main.cpp(148) : error C2059: syntax error : ''bad suffix on number''
c:\code\msvc\opengl test\main.cpp(148) : error C2146: syntax error : missing '')'' before identifier ''f''
c:\code\msvc\opengl test\main.cpp(148) : error C2059: syntax error : ''bad suffix on number''
c:\code\msvc\opengl test\main.cpp(148) : error C2059: syntax error : '')''
c:\code\msvc\opengl test\main.cpp(149) : error C2065: ''glRotate'' : undeclared identifier
c:\code\msvc\opengl test\main.cpp(153) : error C2059: syntax error : ''bad suffix on number''
c:\code\msvc\opengl test\main.cpp(153) : error C2146: syntax error : missing '')'' before identifier ''f''
c:\code\msvc\opengl test\main.cpp(153) : error C2660: ''glVertex3f'' : function does not take 2 parameters
c:\code\msvc\opengl test\main.cpp(153) : error C2059: syntax error : ''bad suffix on number''
c:\code\msvc\opengl test\main.cpp(153) : error C2059: syntax error : ''bad suffix on number''
c:\code\msvc\opengl test\main.cpp(153) : error C2059: syntax error : '')''
Error executing cl.exe.


- f l u c k y p o o
- the geek inside
- f l u c k y p o o
Well the first thing is that on line 113 it looks like you are trying to call RegisterClass with a WNDCLASSEX structure as the parameter. Instead you will need to call RegisterClassEx.

The other errors look like you haven''t includeed the relevent headers and linked to the correct libraries. Although you said you have, so I''m not sure what could be causing them. Make sure you haven''t missed any brackets etc.
Go to the OpenGL link in my signature, download Lesson 1, build it, and look at what is different in your headers. Also, I noticed in glVertex3f you only sent it 2 coordinates, so check your code again.

______________________________
[Books] [Reference and Tutorials]
[For Beginners] [IGDA]
[OpenGL Tutorials] [Sourceforge]
[DirectX Tutorials] [Gamasutra]

[edited by - catfoodgood on May 4, 2002 1:41:00 PM]
c:\code\msvc\opengl test\main.cpp(148) : error C2065: ''glTranslate'' : undeclared identifier its meant to be glTranslatef(0.0f, 0.0f, 0.0f);
glRotatef(0.0f, 0.0f, 0.0f);
glVertex3f(0.0f, 0.0f, 0.0f); (you might want glVertex2f )


--------------------------------

Lead Design, Lead Artist
WhitespaceUnlimited
Where have I been ?

This topic is closed to new replies.

Advertisement