CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Sep 2004
    Posts
    5

    Question How can I deal with this LNK2005 error?

    This is some error ocurred when linking my project, all errors and warnings are listed below:

    JRtest error LNK2005: __afxForceSTDAFX already defined in mfcs71d.lib(stdafx.obj)
    JRtest fatal error LNK1169: one or more multiply defined symbols found
    JRtest warning LNK4098: defaultlib 'mfc71.lib' conflicts with use of other libs; use /NODEFAULTLIB:library
    JRtest warning LNK4098: defaultlib 'mfcs71.lib' conflicts with use of other libs; use /NODEFAULTLIB:library
    JRtest warning LNK4098: defaultlib 'MSVCRT' conflicts with use of other libs; use /NODEFAULTLIB:library

    Who can help me about this, thank you very much!

  2. #2
    Join Date
    Oct 2002
    Location
    Timisoara, Romania
    Posts
    14,360

    Re: How can I deal with this LNK2005 error?

    __afxForceSTDAFX is defined more than once, probably because you linked with two libraries, each of them defining it.

    Here is from MSDN:
    symbol already defined in object

    The given symbol, displayed in its decorated form, was multiply defined.

    Possible causes
    • Accidentally linking with both the single-threaded and multithreaded libraries. Ensure that the application project file includes only the appropriate libraries and that any third-party libraries have appropriately created single-threaded or multithreaded versions.
    • Mixing static and dynamic libraries when also using /clr.
    • The symbol is a packaged function (created by compiling with /Gy) and was included in more than one file but was changed between compilations. Recompile all files that include symbol.
    • The symbol is defined differently in two member objects in different libraries, and both member objects were used.
    • An absolute is defined twice, with a different value in each definition.
    • A header file declared and defined a variable. Possible solutions include:
      • Declare the variable in .h: extern BOOL MyBool; and then assign to it in a .c or .cpp file: BOOL MyBool = FALSE;.
      • Declare the variable static.
      • Declare the variable selectany.
    • If you use uuid.lib in combination with other .lib files that define GUIDs (for example, oledb.lib and adsiid.lib). For example:
      oledb.lib(oledb_i.obj) : error LNK2005: _IID_ITransactionObject
      already defined in uuid.lib(go7.obj)
      To fix, add /FORCE:MULTIPLE to the linker command line options, and make sure that uuid.lib is the first library referenced.
    Marius Bancila
    Home Page
    My CodeGuru articles

    I do not offer technical support via PM or e-mail. Please use vbBulletin codes.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured