?
Solved

regarding linking error LNK2005 - using STL and MFC

Posted on 1999-01-14
2
Medium Priority
?
698 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 31

Accepted Solution

by:
Zoppo earned 120 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

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

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

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 …
Introduction: Finishing the grid – keyboard support for arrow keys to manoeuvre, entering the numbers.  The PreTranslateMessage function is to be used to intercept and respond to keyboard events. Continuing from the fourth article about sudoku. …
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.
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
Suggested Courses
Course of the Month12 days, 1 hour left to enroll

752 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