Re: Including headers in my project

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance

From: muchan (usenet_at_usenet.usenet)
Date: 02/02/05


Date: Wed, 02 Feb 2005 15:13:46 +0100

Wriggler wrote:
>
>
> Hi muchan,
>
> Thanks for the reply. That's exactly what I have, but it gives multiple
> definition errors. I've just done another quick test, which gives exactly the
> same problem:
>
> render.h
> ----------
> #include <gl/gl.h>
> #include <gl/glu.h>
>
> main.cpp
> -----------
> #include "render.h"
>
> render.cpp
> ------------
> #include "render.h"
>
> That's all there is in those three files (just a line or two). I've simply
> made a new empty Win32 application, and added the three files to the project.
> Clicking "build" will give an error about multiple definitions for everything
> inside gl.h and glu.h.
>
> I think it must be something to do with my project settings. I haven't
> actually coded anything which links main.cpp and render.cpp, they are simply
> both included in the same project. I assume VS.NET compiles these two files
> together automatically. Am I doing something wrong here?
>
> Thanks again for your help,
>
> Ben

In this case, it's "devide and conquer" method that may work.

First, compile only the render.cpp, (from the Build menu) and see if it causes
error or warnings.
Then, compile only the main.cpp and see if it causes error or warnings.
If no problem, then link (or just build not build-all) and see if it links OK.

If gl/gl.h or gl/glu.h defines something depends on Win32 or WIN32 definition,
maybe you should include "windows.h" in render.h or each .cpp files before
including the gl.h files.
Maybe these two files expect some keywords are defined for compilation,
or inconsistency of these keywords may cause multiple definitions...

Errors about semicolon is offen seen because of undefined type used in declaration
so check the line number of that error, then see what type it try to declare,
then see if some #ifdef is used for define or declare that type.

I can't think more... hope it helps.

muchan



Relevant Pages

  • Re: Inheritance
    ... I would not define that as "multiple inheritance"... ... to include the b.h file to declare this pointer. ... The proble starts when, in class b, I declare a pointer ... This will not compile with out me including the header file c.h. ...
    (microsoft.public.vc.mfc)
  • Re: Including headers in my project
    ... "muchan" wrote: ... compile only the main.cpp and see if it causes error or warnings. ... > so check the line number of that error, then see what type it try to declare, ...
    (microsoft.public.vc.language)
  • Re: Understanding # and function variables
    ... I wanted to stress it for two reasons. ... will assume you meant to declare it special, ... you establish some bindings at compile ...
    (comp.lang.lisp)
  • Re: When is a static data member defined?
    ... If you just declare a function ... it will compile and link fine as long as you don't ... to implement a language in general. ... memory and a pointer to that table get stored in every object of that ...
    (comp.lang.cpp)
  • Re: Mobile source location
    ... the build, in particular, code that doesn't compile. ... That's the point of the "private branch": that this code gets built only ... Some development projects can take multiple hours, even multiple days, ... it's often true that the unit tests are still incomplete.) ...
    (comp.lang.java.programmer)