Solved

regarding linking error LNK2005 - using STL and MFC

Posted on 1999-01-14
2
678 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 31

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Show shut-down message as Windows 8 shuts down. 9 85
Question regarding Copy/Paste 16 91
iSeries DB2 Query 2 91
Problem to App 4 40
Introduction: Displaying information on the statusbar.   Continuing from the third article about sudoku.   Open the project in visual studio. Status bar – let’s display the timestamp there.  We need to get the timestamp from the document s…
Introduction: The undo support, implementing a stack. Continuing from the eigth article about sudoku.   We need a mechanism to keep track of the digits entered so as to implement an undo mechanism.  This should be a ‘Last In First Out’ collec…
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.
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

863 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

27 Experts available now in Live!

Get 1:1 Help Now