Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Linking error caused by mixing MFC and non MFC style code

Posted on 1998-11-17
2
Medium Priority
?
420 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 600 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

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

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

In this post we will learn different types of Android Layout and some basics of an Android App.
Ready to get certified? Check out some courses that help you prepare for third-party exams.
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.
Integration Management Part 2

824 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