Solved

Linking error caused by mixing MFC and non MFC style code

Posted on 1998-11-17
2
409 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
Comment Utility
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
Comment Utility
It worked
0

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

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. …
Introduction: Hints for the grid button.  Nested classes, templated collections.  Squash that darned bug! Continuing from the sixth article about sudoku.   Open the project in visual studio. First we will finish with the SUD_SETVALUE messa…
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 tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

772 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now