none
fatal error LNK1169: one or more multiply defined symbols found

    Question

  • I know it's something about the includes but I can't figure out how to solve this.

    So I've got 2 header files and 4 cpp files.
    Two cpp files include a different header and the other two files include both headers.
    Like this:

    http://img814.imageshack.us/img814/3594/examplemf.png

    And I'm getting that error... 

    It's a win32 app (no /clr)

    Sunday, August 01, 2010 10:19 PM

Answers

  • If you are *defining* a symbol in one of
    the headers, and that header is included
    in more than one cpp file in the project,
    then that symbol will be *defined* in each
    cpp file that includes the header. Then when
    the linker tries to combine the obj files
    from the compilations into a single exe
    file it finds the symbol *defined* in
    more than one object module. i.e. - It
    *exists* in more than one module.

    The symbol can be *declared only* in the
    header. You need to *define* it in one
    and only one source module (cpp), and
    then in the other source modules it
    needs to be *declared as extern*.

    - Wayne
    Sunday, August 01, 2010 10:49 PM