Solved

regarding linking error LNK2005 - using STL and MFC

Posted on 1999-01-14
2
676 Views
Last Modified: 2013-11-20
hi everyone
i have written a program in which i am using "STL map" class and "MFC date"
classes. if i link the program using static linkage of MFC library then
the following linking errors come :

But if i link the program using "MFC library as dyamic" then the link error does not
come. i want to use static linkage due to performance point of view of
the program.

**********************************************************************
The linking error alongwith their description are as follows :

Linking...
nafxcwd.lib(afxmem.obj) : error LNK2005: "void __cdecl operator delete(void *)" (??3@YAXPAX@Z) already defined in libcpmtd.lib(delop.obj)
Debug/bill.exe : fatal error LNK1169: one or more multiply defined symbols found
Error executing link.exe.
*****************************************************************
For reference of description of error i am pasting the help on the error as given in VC :

Linker Tools Error LNK2005
---------------------------
symbol already defined in object
The given symbol, displayed in its decorated form, was multiply
defined.

Tips
---
One of the following may be a cause:

The most common cause of this error is 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.

The given symbol was 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 the symbol.

The given symbol was defined differently in two member objects in
different libraries, and both member objects were used.
An absolute was defined twice, with a different value in each
 definition.

This error is followed by fatal error LNK1169.

********************************************************************

I will be highly greatful if u could help me. waiting for the reply
thanks in advance

amit
0
Comment
Question by:aarya
2 Comments
 
LVL 30

Accepted Solution

by:
Zoppo earned 30 total points
ID: 1327714
Found some info in MSDN Article ID: Q148652 :

.
The CRT libraries use weak external linkage for the new, delete, and DllMain functions. The MFC libraries also contain new, delete, and DllMain functions, requiring MFC to be linked before the CRT libraries.
.

The solution involves forcing the linker to link the libraries in the correct order.

1. Open the Project Settings dialog box by clicking Settings on the Build menu.
2. in the Settings For view, select (highlight) the project configuration that's getting the link errors.
3. Click the Link tab.
4. Select INPUT in the Category combo box.
5. In the Libraries to Ignore edit box, insert the library names (for example, Nafxcwd.lib Libcmtd.lib)
6. In the Object/library Modules edit box, insert the library names. You must ensure that these are listed in order and as the first two libraries in the line (for example, Nafxcwd.lib Libcmtd.lib).

An other solution might be to check the 'Force File Output'-checkbox in Settings-Link-Customize

hope that helps,

ZOPPO
0
 

Author Comment

by:aarya
ID: 1327715
THANKS A LOT ZOPPO .. I was able to link the project. Zoppo if it does not bother u i would like to know ur email id (WONT BOTHER U MUCH ;-) )
my email id being : amit_arya@rocketmail.com and
                    aarya@cdotd.ernet.in
Waiting for ur reply.
AGAIN THANKS A TON

PS :
ZOPPO would u care telling me a little about the libraries u mentioned. (i can assume Nafxcwd.lib would be for mfc whats the other library for)



0

Featured Post

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
configuration management 2 99
cat dog challenge 18 122
sum28 challenge 31 96
Problem to event 3 49
In this article, I'll describe -- and show pictures of -- some of the significant additions that have been made available to programmers in the MFC Feature Pack for Visual C++ 2008.  These same feature are in the MFC libraries that come with Visual …
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
This video discusses moving either the default database or any database to a new volume.

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now