LNK2005 error

    Question by:
    On

    Topics:

    Another link error:

    nafxcwd.lib(afxmem.obj) : error LNK2005: "void * __cdecl operator new(unsigned int)" (??2@YAPAXI@Z) already defined in LIBCMTD.lib(new.obj)
    nafxcwd.lib(afxmem.obj) : error LNK2005: "void __cdecl operator delete(void *)" (??3@YAXPAX@Z) already defined in LIBCMTD.lib(dbgdel.obj)
    .\Debug\foo.exe : fatal error LNK1169: one or more multiply defined symbols found

    So LIBCMTD.lib is a standard C runtime library, multithreaded and Nafxcwd.lib is afx, debug version

    I have the /MTd option in Project Setting -> C/C++

    Suggested solutions to this problem that I've seen elsewhere on the net involve changing options on the Project Settings "Link" tab, which I have do not have

    Using VC++6

    Good Question?
    0
     

    ?

    The member who asked this question verified this comment provided the solution that solved their problem.

    Accepted Solution on 2001-12-24 at 12:43:25ID: 6693108

    You need to change the order in which the libraries are linked.  Try this:
    http://support.microsoft.com/default.aspx?scid=kb;EN-US;q148652

    verified

    answer

    Enjoy your free answer!

    Join now to get more tech resources.

    Become a member

    Comments

     
    alexo

    Expert Comment

    2001-11-02 at 09:43:22ID: 6614233
    What tabs do you have?  Are you using an external makefile?
    Good Comment?
    0
     
    omom

    Author Comment

    2001-11-02 at 10:49:44ID: 6614471
    >>What tabs do you have
    Project setting tabs are:
    General, Debug, Fortran, C/C++, Resources, Browse Info, Custom Build, Pre-link step, Post-build step

    >>Are you using an external makefile?
    The first line of foo.mak (the project make file) reads:
    # Microsoft Developer Studio Generated NMAKE File, Format Version 40001

    Good Comment?
    0
     
    speedguns

    Expert Comment

    2001-11-02 at 13:23:31ID: 6614768
    Hey Omom,  Which setting do you want to change on the link tab,  I will look on my VC to  to see what the command line option is,  and you can enter it elsewhere (other than the link tab)  ?

    By the way,  the real problem here, is that the link tab is missing from your settings dialog,   I wonder how
    one goes about getting that back,  I am sure it's a function of you workspace.  I will check out a working
    workspace on my machine on monday, and get back to you if, you havn't closed this yet.
    Good Comment?
    0
     
    alexo

    Expert Comment

    2001-11-02 at 13:35:58ID: 6614790
    Assuming

    Open the makefile with your favorite editor.
    Find the LINK32_FLAGS entries.
    Add /nodefaltlib to each.
    Good Comment?
    0
     
    omom

    Author Comment

    2001-11-02 at 13:42:31ID: 6614802
    speedguns:
    I would definitely appreciate whatever you can find out about the link tab
    Good Comment?
    0
     
    omom

    Author Comment

    2001-11-02 at 13:52:32ID: 6614828
    alexo:
    Since thet make file is generated by Dev Studio, if I make the change suggested, will it not the file be written over and the changes lost?
    Good Comment?
    0
     
    alexo

    Expert Comment

    2001-11-02 at 14:03:03ID: 6614846
    I don't know, you have a weird setup...

    If you have a .dsp file, add the switch to lines beginning with either:
    # ADD BASE LINK32
    # ADD LINK32
    Good Comment?
    0
     
    speedguns

    Expert Comment

    2001-11-02 at 14:38:54ID: 6614907
    You do have a weird setup,  but instead of typing alexo's suggestion (which is probably the correct answer)
    into the makefile,  can you just stuff it into the project options in the C/C++ tab?  Might not work though,  not
    like the simple solution to the Directory thing.  
    Good Comment?
    0
     
    alexo

    Expert Comment

    2001-11-02 at 18:24:10ID: 6615306
    >> can you just stuff it into the project options in the C/C++ tab?

    It will not work because it is a linker option, not a compiler one.
    Good Comment?
    0
     
    omom

    Author Comment

    2001-11-07 at 06:49:12ID: 6624812
    Hold on, please...fighting fires...also, I may try reinstalling VC++ to see if I get a link tab.
    Good Comment?
    0
     
    alexo

    Expert Comment

    2001-11-07 at 08:10:24ID: 6625020
    Before you reinstall, try just creating a new C++ project and see if that one has a "link" tab.  If so, it might be better for you to migrate your project to a new one.
    Good Comment?
    0
     
    omom

    Author Comment

    2001-11-29 at 15:02:40ID: 6660522
    Ok, let?s start once again?the error is:

    Linking...
    nafxcwd.lib(afxmem.obj) : error LNK2005: "void * __cdecl operator new(unsigned int)" (??2@YAPAXI@Z) already defined in LIBCMTD.lib(new.obj)
    nafxcwd.lib(afxmem.obj) : error LNK2005: "void __cdecl operator delete(void *)" (??3@YAXPAX@Z) already defined in LIBCMTD.lib(dbgdel.obj)
    .\Debug\Ecotone.exe : fatal error LNK1169: one or more multiply defined symbols found
    Error executing link.exe.

    Contrary to my original statement AN EXTERNAL LINK FILE  IS BEING USED.

    alexo:
    You suggested to add /nodefaltlib to LINK32_FLAGS
    I have 2 lines in the make file like this:

    LINK32_FLAGS=kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib LIB00.lib /nologo /subsystem:windows /pdb:none /debug\

    I added /nodefaultlib, to no effect, but that might be jummping the gun.

    There is a problem with the file path.
    When I do a Rebuild All, it can?t find the source code because the path is wrong.  For example, the file is in C:\dir1\dir2\foo.cpp.  The compiler says it can?t c:\dir1\dir2\dir2\foo.cpp. Notice -> ?dir2\dir2?
    Good Comment?
    0
     
    omom

    Author Comment

    2001-11-30 at 07:01:56ID: 6662022
    It occurs to me that I'm proceeding incorrectly.

    I've inherited this project, with none of previous authors around to give me any direction, so I'm learning as I go.

    I've discerned that the project was built with an external make file.  I've never done this, I've only built C++ projects from within VC++.  So I am probably not taking the proper steps to build correctly.
    Good Comment?
    0
     
    alexo

    Expert Comment

    2001-11-30 at 07:39:29ID: 6662142
    Why don't you scrap this project and built a new one from scratch?  You can copy most settings from the existing makefile.

    Then, you can generate a makefile from the project.
    Good Comment?
    0
     
    omom

    Author Comment

    2001-11-30 at 08:03:42ID: 6662212
    Originally, I did a File -> Open Workspace, then selected the foo.mak file.  VC++ then creates the project from the make file.  So at this point I have a project, but I get the previously mention errors.  Do I need to build from the command prompt?

    I would like to continue using building the project via the make file.  I think this makes it easier to move to another system.

    Good Comment?
    0
     
    alexo

    Expert Comment

    2001-11-30 at 09:46:01ID: 6662420
    I meant, create a *new* project from scratch.
    Good Comment?
    0
     
    omom

    Author Comment

    2001-12-24 at 12:16:21ID: 6693095
    Ok, i have a link tab

    according to instructions at support.microsoft.com:

    * Open the Project Settings dialog box by clicking Settings on the Build menu.
    * In the Settings For view, click to select (highlight) the project configuration that is getting the link errors.
    * Click the Link tab.
    * Click to select INPUT in the Category combo box.
    * In the Libraries to Ignore edit box, insert the library names (for example, Nafxcwd.lib Libcmtd.lib).

    I add these 2 libraries to the "Ignore Libraries" list but i get the same link errors

    I check "Ignore All Default Libraries" and I get hundreds of errors of unresolved external symbols

    What to try next?

    Good Comment?
    0
     
    omom

    Author Comment

    2001-12-24 at 12:36:54ID: 6693106
    Also, this link error occurs only when building for Debug.  When building for Release, no errors.
    Good Comment?
    0
      

    Accepted Solution

    2001-12-24 at 12:43:25ID: 6693108Best
    alexo earned 200 total points
    You need to change the order in which the libraries are linked.  Try this:
    http://support.microsoft.com/default.aspx?scid=kb;EN-US;q148652
    Good Solution?
    0
     
    omom

    Author Comment

    2001-12-24 at 14:24:56ID: 6693165
    Ok, the answer is to add Nafxcwd.lib Libcmtd.lib to the Ignore Libraries field AND add them to the front of the Object Library Modules
    Good Comment?
    0

    Featured Post

    Course: AWS Professional Certification

    These classes are designed to help you pass the AWS Certified Solutions Architect – Associate, AWS Certified Developer, and AWS Certified SysOps Administrator Associate exams—all essential to a career as an AWS professional.

    Ask Your Tech Question. Get Expert Solutions.We will email you as soon as we have your answer.

    We will never share this with anyone.

    Select topics

    You may select up to five topics.

    Top Expert Contributor

    Essential articles and videos from the Experts

    This tutorial is about how to put some of your C++ program's functionality into a standard DLL, and how to make working with the EXE and the DLL simple and seamless.   We'll be using Microsoft Visual Studio 2008 and we will cut out the noise; that i…
    A theme is a collection of property settings that allow you to define the look of pages and controls, and then apply the look consistently across pages in an application. Themes can be made up of a set of elements: skins, style sheets, images, and o…
    This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
    Need more eyes on your posted question? Go ahead and follow the quick steps in this video to learn how to Request Attention to your question. *Log into your Experts Exchange account *Find the question you want to Request Attention for *Go to the e…

    More valuable questions with Expert answers

    Question: Hi, Within Excel 2010, how can I see the details of the column/field of one Pivot table?

    Answer: Try this.... (CODE)

    Question: We are looking to recruit a university graduate to assist with maintaining monitoring and developing a number of in house applications built based on MSAccess/VBA. it is a fairly junior role, but as I don't work directly with the access/VBA...

    Answer: In the UK, they use Access as a teaching tool in universities so students there have a positive view of it as a product. In the US, "professionals" look down on it so I'd weed out anyone who thinks Access is a toy. What you don't want to end up...

    Question: How do you perform a clean uninstall of Visual Studio Professional 2015? Clicking Tools -> Extensions and Updates throws the following error: Object reference not set to an instance of an object. Clicking Help -> View Help throws the...

    Answer: Choose Control Panel > Program and feature > Choose VS 2015 item > Right-click to uninstall

    Question: I am not sure what it means to code using WebAPI. Please give me a few examples. Thanks

    Answer: Hi newbieweb; Books have been written on the subject and too much to post here. Here is a web site with many samples / tutorials, Learn About ASP.NET Web API (http://www.asp.net/web-api), This is a web page with documentation, ASP.NET Web API...

    201607-LO-Qu-086

    Extend your technology team with the Experts Exchange community.

    — trusted by —

    Who answers my questions?Our community has technology experts around the world.

    Paweł

    70

    Solutions

    ☠ MASQ ☠

    6

    Articles

    8,780

    Solutions

    Expert in:

    • Computer Games
    • Hardware-Other
    • Windows XP
    • Components
    • Laptops/Notebooks

    als315

    1

    Articles

    2,096

    Solutions

    Expert in:

    • MS Access
    • MS Excel
    • MS Applications
    • MS Office
    • Query Syntax

    Zoppo

    1

    Articles

    2,133

    Solutions

    Expert in:

    • C++
    • System Programming
    • C
    • Editors IDEs
    • MS Development-Other

    chaau

    750

    Solutions

    Expert in:

    • MS SQL Server
    • MS Access
    • MS SQL Server 2008
    • Query Syntax
    • .NET Programming

    Tapan Pattanaik

    735

    Solutions

    Expert in:

    • .NET Programming
    • ASP.NET
    • C#
    • MS SQL Server
    • Web Development-Other

    Fernando Soto

    5,180

    Solutions

    Expert in:

    • .NET Programming
    • C#
    • Visual Basic.NET
    • ASP.NET
    • Editors IDEs

    Erik Bjers

    1,036

    Solutions

    Expert in:

    • Networking-Other
    • Windows Networking
    • Windows Server 2003
    • Active Directory
    • DNS

    DanRollins

    84

    Articles

    4,770

    Solutions

    Expert in:

    • MS Development-Other
    • System Programming
    • C++
    • Editors IDEs
    • JavaScript

    RELATED TOPICS view all topics

    1. .NET Programming
      (130,871)
    2. Visual Basic Classic
      (163,326)
    3. Visual Basic.NET
      (91,311)
    4. MS Access
      (214,527)
    5. MS Applications
      (43,059)
    6. ASP.NET
      (122,584)
    7. MS SQL Server
      (155,368)
    8. C#
      (90,572)
    9. C++
      (56,810)
    10. Editors IDEs
      (24,918)
    Receive Monthly Emails of Tech News and Trends from Experts Exchange