G
Guest
Hi guys, this *should* be a simple problem, but I've never really got my head
around it. I'm hoping somebody on this message board could help me out? I
don't really have any experience with VS.NET, which is probably why I'm
having so much trouble!
Basically, I've been doing some OpenGL coding using VS.NET as the compiler.
Obviously (if you know any OGL), you'll know I need to include gl.h and glu.h
to have access to all the drawing functions.
Whilst I've been working through the tutorials, all of the code has always
been in a single .cpp file. The two .h files are included at the top, and
that's that. However, I've been trying to split up my classes into different
..cpp files, which has given me all sorts of problems.
If I include the headers at the top of main.cpp only, I get complaints from
the renderClass.cpp file saying that it can't find the definitions it needs.
If I include the headers at the top of renderClass.cpp only, I get all sorts
of errors INSIDE the header itself. Apparantly there are lots of semi-colons
missing from gl.h, which I'm pretty sure there aren't!!
If I include the headers in both files, I get multiple definition errors all
over the place. If I try and use #ifdef and #ifndef then I find that the
defintions aren't made in the second file, so it's back to square one!
So, my question is... How do I go about including a header file into
multiple C++ sources, so that both .cpp files can use the information, but
avoiding multiple defintion errors?
I know this is elementary stuff, but I've never figured it out. Am I just
approaching this the wrong way? Thanks in advance to anybody who can help!
Cheers,
Ben
around it. I'm hoping somebody on this message board could help me out? I
don't really have any experience with VS.NET, which is probably why I'm
having so much trouble!
Basically, I've been doing some OpenGL coding using VS.NET as the compiler.
Obviously (if you know any OGL), you'll know I need to include gl.h and glu.h
to have access to all the drawing functions.
Whilst I've been working through the tutorials, all of the code has always
been in a single .cpp file. The two .h files are included at the top, and
that's that. However, I've been trying to split up my classes into different
..cpp files, which has given me all sorts of problems.
If I include the headers at the top of main.cpp only, I get complaints from
the renderClass.cpp file saying that it can't find the definitions it needs.
If I include the headers at the top of renderClass.cpp only, I get all sorts
of errors INSIDE the header itself. Apparantly there are lots of semi-colons
missing from gl.h, which I'm pretty sure there aren't!!
If I include the headers in both files, I get multiple definition errors all
over the place. If I try and use #ifdef and #ifndef then I find that the
defintions aren't made in the second file, so it's back to square one!
So, my question is... How do I go about including a header file into
multiple C++ sources, so that both .cpp files can use the information, but
avoiding multiple defintion errors?
I know this is elementary stuff, but I've never figured it out. Am I just
approaching this the wrong way? Thanks in advance to anybody who can help!
Cheers,
Ben