Solved

Linking error caused by mixing MFC and non MFC style code

Posted on 1998-11-17
2
411 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
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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Best tools for Backup and restore of Wordpress site 6 57
difference between String.subString() and String.subSequence() 6 193
Fibonacci challenge 11 120
Problem to event 3 92
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…
If you use Adobe Reader X it is possible you can't open OLE PDF documents in the standard. The reason is the 'save box mode' in adobe reader X. Many people think the protected Mode of adobe reader x is only to stop the write access. But this fe…
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…

808 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