none
error LNK2005 RRS feed

  • Question

  • Hi, i know this has been post many times, i have read them, but couldn't solve my problem, so i hope anyone can help, I am using Visual Studio 2008, and I get following errors:

    1>test.obj : error LNK2005: "char * str" (?str@@$$Q3PADA) already defined in Tester.obj

    1>C:\Users\Vepa\Documents\Visual Studio 2008\Projects\Project1\Tester\Debug\Tester.exe : fatal error LNK1169: one or more multiply defined symbols found

    Any help?

     

     

    Tuesday, September 7, 2010 10:38 PM

Answers

  • This is typically due to defining a variable in a header file rather than a source file. If you have a header file containing:

    char* str;

    and include the header file in two source files, you have defined the same variable twice.

    Variables can be declared in a header file, but should be defined in a source file.

    • Marked as answer by Vepashka Wednesday, September 8, 2010 1:18 AM
    Wednesday, September 8, 2010 12:10 AM

All replies

  • This is typically due to defining a variable in a header file rather than a source file. If you have a header file containing:

    char* str;

    and include the header file in two source files, you have defined the same variable twice.

    Variables can be declared in a header file, but should be defined in a source file.

    • Marked as answer by Vepashka Wednesday, September 8, 2010 1:18 AM
    Wednesday, September 8, 2010 12:10 AM
  • aha, ok i got you
    Wednesday, September 8, 2010 1:18 AM