Solved

Linking error caused by mixing MFC and non MFC style code

Posted on 1998-11-17
2
416 Views
Last Modified: 2013-11-20
I've been trying to include a few files such as my own Matrix library with an MFC app. The problem I run into is a linking error caused by two libraries defining the same symbol.

nafxcwd.lib(afxmem.obj) : error LNK2005: "void * __cdecl operator new(unsigned int)" (??2@YAPAXI@Z) already defined in LIBCMTD.lib(new.obj)
nafxcwd.lib(afxmem.obj) : error LNK2005: "void __cdecl operator delete(void *)" (??3@YAXPAX@Z) already defined in LIBCMTD.lib(dbgdel.obj)
nafxcwd.lib(afxmem.obj) : error LNK2005: "void * __cdecl operator new(unsigned int,int,char const *,int)" (??2@YAPAXIHPBDH@Z) already defined in LIBCMTD.lib(dbgnew.obj)
Debug/TestStaticPos.exe : fatal error LNK1169: one or more multiply defined symbols found

The non-MFC code is not using a precompiled header.I know its caused by something in the project settings but I haven't been able to track it down.

If you've seen this before and have found a way around it, Please respond.
0
Comment
Question by:gmacgougan
[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 2

Accepted Solution

by:
wyy_cq earned 200 total points
ID: 1324858
only rebuild your library.
when you do that you need to select "use mfc in static link"

or you can rebuild your library as DLL.
if you only export C function from the DLL, it is easy and simple.
but if you want to export C++ class from the DLL you must select "use mfc in static link" or "use mfc in shared link" ,what choice is made occording to your application project setting.
0
 

Author Comment

by:gmacgougan
ID: 1324859
It worked
0

Featured Post

Percona Live Europe 2017 | Sep 25 - 27, 2017

The Percona Live Open Source Database Conference Europe 2017 is the premier event for the diverse and active European open source database community, as well as businesses that develop and use open source database software.

Question has a verified solution.

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

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.
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …

615 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