Sign in to follow this  
Kaidan Alenko

Invalid or corrupt .h file?

Recommended Posts

I'm building a source code of mine in which I get an unresolved external symbol error for each GL and GLUT function call I make; these errors happen during the Linking process. Figuring it might solve the problem, I added GL.h GLU.h and glut.h into my "Additional Dependencies" option in Microsft Visual C++ 2008. Now I'm getting the following error for all three files, with their respective names (meaning not every error says gl.h) C:\Program Files\Microsoft Visual Studio 9.0\VC\include\GLU.h : fatal error LNK1107: invalid or corrupt file: cannot read at 0x476C Do you think my files are the problem?

Share this post


Link to post
Share on other sites
No. Header files are not libraries -- they're header files (see here). The "additional dependencies" line is for linking to libraries.

The error you got is a linker error, which indicates that your source code compiled successfully but could not be linked into a final executable. What you want is to add the OpenGL libraries (typically opengl32.lib) to that line, not the header files.

Share this post


Link to post
Share on other sites
Is there any other opengl library I need to add to the list? That is just the thing, I have OpenGL32.lib (located in VC\lib) on that list and I continue to get the 16 unresolved external symbols.

Share this post


Link to post
Share on other sites
If you're using GLU functions you'll need to add the library for GLU. Generally it's Glu32.lib. If you're using GLUT functions, you'll need to add the library for GLUT. It's generally called glut32.lib.

Share this post


Link to post
Share on other sites
Much thanks, that resolves the unresolved externals for GLU and GLUT. Is there any other lib file I need for GL commands, along with OpenGL32.lib? GLU and GLUT errors are gone, however I'm receiving 10 errors for gl functions, for example:

OpenGLtest.obj : error LNK2019: unresolved external symbol __imp__glOrtho@48 referenced in function "void __cdecl ChangeSize(int,int)" (?ChangeSize@@YAXHH@Z)

OpenGLtest.obj : error LNK2019: unresolved external symbol __imp__glViewport@16 referenced in function "void __cdecl ChangeSize(int,int)" (?ChangeSize@@YAXHH@Z)

Share this post


Link to post
Share on other sites
Huh, I thought we went over this already. You downloaded some weird opengl-looking libraries from god-knows-where, and that's not how to go about it. Rather, all you need to do is install the latest version of the Platform SDK which includes them (available here; note that despite the name it supports all Windows versions since XP).

Share this post


Link to post
Share on other sites
Quote:
I thought we went over this already...all you need to do is install the latest version of the Platform SDK

In all fairness, Sneftel, with regard to what "we went over" in the other thread, a search for "platform sdk" or "opengl sdk" on msdn downloads doesn't return useful results. No indication of opengl support is mentioned, so determining which "platform sdk" you intended was difficult at best. The "Visual Studio 2008 SDK" (the next best guess) does not, in fact, have opengl files.

Share this post


Link to post
Share on other sites
Quote:
Original post by Buckeye
Quote:
I thought we went over this already...all you need to do is install the latest version of the Platform SDK

In all fairness, Sneftel, with regard to what "we went over" in the other thread, a search for "platform sdk" or "opengl sdk" on msdn downloads doesn't return useful results. No indication of opengl support is mentioned, so determining which "platform sdk" you intended was difficult at best. The "Visual Studio 2008 SDK" (the next best guess) does not, in fact, have opengl files.
But in the other thread on the 18th:
Quote:
Original post by Kaidan Alenko
Indeed, we are talking about the Windows Platform SDK.
So it seems he figured out what he needed despite his using out-of-date terminology. Also, if you search for just "platform sdk" the third link provides a detailed listing of the different SDKs with a link to the download page. I do concede there might be an issue if you don't believe that the 'platform sdk' contains opengl related things. The SDKs contain a lot of stuff and it isn't always easy to find out if the thing you want is actually in it.

Share this post


Link to post
Share on other sites
The other thread didn't fix my problem. I already have the OpenGL32.lib file from the Windows Platform SDK. That is the one I am using to link. SiCrane's advice has fixed 6 of my error messages. I know you're probably irritated I'm asking about it again, I don't appreciate the berating I feel I'm getting.

Back to my unanswered question, is there any other .lib files I'll need to add aside from OpenGL32.lib, GLU.lib, and glut.lib in order for OpenGL to work? There has to be, I'm still getting error messages even with OpenGL32.lib linked.

Share this post


Link to post
Share on other sites
Nope. All calls that begin with gl* come from opengl32.lib. If you're still getting linker complaints from them then you're using the wrong version of opengl32.lib. What did you download? AFAIK visual c++ 2008 comes with everything you need for opengl out of the box.

Share this post


Link to post
Share on other sites
Quote:
Original post by Buckeye
In all fairness, Sneftel, with regard to what "we went over" in the other thread, a search for "platform sdk" or "opengl sdk" on msdn downloads doesn't return useful results. No indication of opengl support is mentioned, so determining which "platform sdk" you intended was difficult at best. The "Visual Studio 2008 SDK" (the next best guess) does not, in fact, have opengl files.
I don't usually use Microsoft search, so I'm not sure what it returns, but if you Google "Platform SDK", click the very first result, and install the resulting file, you will be able to use OpenGL. You can install pretty much any Platform SDK you want, since it's not like Windows' OpenGL support has changed much since Windows 95. But that's a good point -- the most recent versions of the PSDK have also been labeled "Windows SDK", so there's some potential confusion there. As for the "Visual Studio 2008 SDK", that is, as the name would suggest, an SDK for developing extensions to Visual Studio, and has nothing to do with OpenGL.

Share this post


Link to post
Share on other sites
Quote:
Original post by DaedalusOwnsYou
AFAIK visual c++ 2008 comes with everything you need for opengl out of the box.
It does, but it's possible that he actually has Visual Studio Express instead (or does that come with the PSDK these days?), or that he deselected the PSDK component during installation. In either case, installing the PSDK is the solution.

Share this post


Link to post
Share on other sites
Quote:
Original post by Sneftel
Quote:
Original post by DaedalusOwnsYou
AFAIK visual c++ 2008 comes with everything you need for opengl out of the box.
It does, but it's possible that he actually has Visual Studio Express instead (or does that come with the PSDK these days?), or that he deselected the PSDK component during installation. In either case, installing the PSDK is the solution.


I use the express version (I'm no expert, and windows isn't my platform of choice) and my (admittedly very simple) tests using opengl always ran out of the box. If I'm unintentionally doing something extra that makes it go on my machine I'd love to here about it so I can replicate it when I need to.

Share this post


Link to post
Share on other sites
You might only be using code that is supported by OpenGL 1.1. Windows, un-modified, only supports up to OpenGL 1.1. I hate Windows =/.

My source code uses OpenGL 1.1+ code, which is why Microsoft SDKs (the folder name of my Window SDK download) as an additional library directoryI have to modify my files in order to use OpenGL. Ok guys, I've removed and re-downloaded the Windows SDK. Is there anything else I have to do, or would simply linking to the microsoft SDK work instead of moving the OpenGL32.lib file over into the VS directory?

Share this post


Link to post
Share on other sites
Quote:
Original post by Kaidan Alenko
You might only be using code that is supported by OpenGL 1.1. Windows, un-modified, only supports up to OpenGL 1.1. I hate Windows =/.
If you install drivers for your graphics card, you can use the latest OpenGL version provided by the graphics card vendor.

On a majority of Windows 7 machines, Microsoft Update will install the correct graphics drivers by itself, the first time you boot up.
Quote:
My source code uses OpenGL 1.1+ code, which is why I have to modify my files in order to use OpenGL.
You don't need to touch the libraries at all. Just install the platform SDK (comes with Visual Studio Express automatically) and graphics card drivers (comes with Windows, usually automatically).

After that, it is just a matter of loading the correct extension pointers (in your own source code), or using one of GLee or GLEW to do it for you.

Share this post


Link to post
Share on other sites
Well guys I thank you for your time and patient help. The problem is fixed.. had to download Windows SDK and properly link it. I truly appreciate your help. The most irritating weeks of my life are over =/.

Share this post


Link to post
Share on other sites
Nah, come to think of it, several of my students last semester were using VS Express, and none of them had to go out of their way to get OpenGL working. So the only thing I can think of is that he explicitly disabled the PSDK installation, not realizing that it included OpenGL support. Or I suppose it could be that he never actually tried it before putting new OpenGL stuff everywhere, but that seems rather unlikely.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this