[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

regarding linking error LNK2005 - using STL and MFC

Posted on 1999-01-14
2
Medium Priority
?
707 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

Introduction: Dynamic window placements and drawing on a form, simple usage of windows registry as a storage place for information. Continuing from the first article about sudoku.  There we have designed the application and put a lot of user int…
Introduction: Database storage, where is the exe actually on the disc? Playing a game selected randomly (how to generate random numbers).  Error trapping with try..catch to help the code run even if something goes wrong. Continuing from the seve…
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 tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
Suggested Courses

650 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