Solved

regarding linking error LNK2005 - using STL and MFC

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

Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

Question has a verified solution.

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

Introduction: Dialogs (1) modal - maintaining the database. Continuing from the ninth article about sudoku.   You might have heard of modal and modeless dialogs.  Here with this Sudoku application will we use one of each type: a modal dialog …
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
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.
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

809 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