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

    Question

  • I have defined a C++ project containing header and source files for the following files:

    matrix. h
    matrix. cpp

    quaternion. h
    quaternion. cpp

    rowvector. h
    rowvector. cpp

    vector. h
    vector. cpp


    In each of these classes I have defined a function called Norm. But when I compile I get:

    1>matrix.obj : error LNK2005: "double __cdecl Norm(double const &,unsigned int)" (?Norm@@YANABNI@Z) already defined in columnvector.obj

    1>quaternion.obj : error LNK2005: "double __cdecl Norm(double const &,unsigned int)" (?Norm@@YANABNI@Z) already defined in columnvector.obj

    1>rowvector.obj : error LNK2005: "double __cdecl Norm(double const &,unsigned int)" (?Norm@@YANABNI@Z) already defined in columnvector.obj

    1>vector.obj : error LNK2005: "double __cdecl Norm(double const &,unsigned int)" (?Norm@@YANABNI@Z) already defined in columnvector.obj

    1>C:\Documents and Settings\bob\Skrivebord\test\bob\Debug\bob.exe : fatal error LNK1169: one or more multiply defined symbols found


    I know that it compiles fine on Linux, but is there some rules on windows that you cannot have different classes with the same name for a function?

    Friday, August 01, 2008 9:28 PM

Answers

  • There is no such limitation.  I guess in your cpp file, you didn't put the classname in front of the function Norm.

    Like:  double RowVector::Norm(double, unsigned int )   NOT  double Norm(double, unsigned int ) .

    This posting is provided "AS IS" with no warranties, and confers no rights.
    Saturday, August 02, 2008 12:17 AM

All replies

  • There is no such limitation.  I guess in your cpp file, you didn't put the classname in front of the function Norm.

    Like:  double RowVector::Norm(double, unsigned int )   NOT  double Norm(double, unsigned int ) .

    This posting is provided "AS IS" with no warranties, and confers no rights.
    Saturday, August 02, 2008 12:17 AM
  • According to your question i think you are getting error due to circulr refrence only. This you can understand you are calling a File A .h in b.h and then again b.h inside A.h .Just have a look inside your code .Hopefully u will get your ans

    Thanx

    It has become appallingly obvious that our technology has exceeded our humanity
    Saturday, August 02, 2008 9:22 AM