This is a really stupid question but it is really pissing me off and I don’t know how to fix it. This is the first time I’ve ever tried to build an OpenGL project with multiple files (usually I just stuck to using one file which was quite messy-which is why I’m trying to use multiple files now). Anyways, my problem is that in my Main.cpp file (where WinMain and everything else starts up) I make sure to include all the necessarry OpenGL files before any of my user-defined include files, however, VC++ is giving me no end of errors regarding the fact that in my user-defined files it can’t recognize the OpenGL functions I am using, in other words, the OpenGL functions aren’t being “included” before my files are, however, they obviously are being included in main long before my files are. I hope that makes some kind of sense!! Please help me!!!
Well from what you say, it is probably a simple matter of not linking the libraries to your project Add the following lines to the top of your code and your set to go
// Link the libaries manually
// This can be done through going through the menus on the IDEs, but this way is cooler and i don’t have to worry about telling you where to go (it’s different on different versions). This code works for any of the versions (it is C after all)
#pragma comment (lib, “opengl32”)
#pragma comment (lib, “glu32”)
#pragma comment (lib, “glaux”)
Thanks Halcyon, I tried it but that’s not the problem. I already had all the libraries linked in in the IDE, but I tried it anyways and it still didn’t work =\ I think it’s something else, but I still don’t know what! Anyone else wanna try?
if you have source files other than your Main.cpp file that need the opengl headers, then you need to include the appropriate headers from those source files as well.
for example, let’s say you have Main.cpp and Texture.cpp, and both files need the opengl headers. then it’s not enough to just include the headers in Main.cpp. you also need to include the headers in Texture.cpp.
Hahahahaha!! Thanks SThomas. You just proved that I am a moron!! I thought that I had already tried what you had suggested, but apparently I didn’t put the includes in ALL the files I needed, so upon a more careful re-check, I discovered the problem and now it works! Thanks for pointing it out to me =)