lnk2005 issue with nafxcw.lib and libc.lib

J

jason.pirok

I've been reading other groups related to this error and I'm only
getting more confused. I'm still quite new to MC++ and I could use a
swift kick in the right direction. The application I'm developing is a
mixed mode Managed wrapper dll.

I have written a class to encapsulate the unmanaged code.

I have also created a managed wrapper class that uses the unmanaged
class

I've been reading a lot concerning a stackoverflowexception, so I have
the /INCLUDE:DLLetc and the /NODEFAULTLIB:nochkclr.obj on purpose. The
project compiles clean but I get these link errors:

nafxcw.lib(afxmem.obj) : error LNK2005: "void * __cdecl operator
new(unsigned int)" (??2@YAPAXI@Z) already defined in libc.lib(new.obj)
D:\libprt\Debug\libxxx.dll : fatal error LNK1169: one or more multiply
defined symbols found
NMAKE : fatal error U1077: 'link' : return code '0x491'
Stop.

I am compiling everything via nmake on the command line because the
project wouldn't remove the /FU mscorlib from my unmanaged .cpp file.

I'm not sure what else to say regarding this. I'm just lost at this
point and I need some guidance as to how to change my command line to
include the right library versions to get rid of my linker errors. If
you see any other issues with my code please feel free to comment.

Thanks for the help

Jason


These are the includes for my unmanaged class

//added because of http://support.microsoft.com/?kbid=814472
#include "stdafx.h"
#include <afx.h>
#include <windows.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include "_vcclrit.h"

//includes for poprietary code
#include "inc_path\xx.h"
#include "inc_path\xxx.h"
#include "inc_path\xxx.h"
#include "inc_path\xxxx.h"
#include "inc_path\xxxxx.h"

These are the includes for my managed class

//added because of http://support.microsoft.com/?kbid=814472
#include "stdafx.h"
#include "unmanaged class header.h"
#include <windows.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include "_vcclrit.h"

these are my linker options:

/NOENTRY /NODEFAULTLIB:"libcmt.lib nochkclr.obj"
/INCLUDE:__DllMainCRTStartup@12 /OUT:"D:\libxxx\Debug\libxxx.dll"
/INCREMENTAL /NOLOGO /LIBPATH:"D:\libxxx\lib" /DLL /FIXED:No libc.lib
libc.lib nafxcw.lib mscoree.lib msvcrt.lib proprietary.lib
"d:\libxxx\xxx.obj" "d:\libxxx\xxxx.obj"
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top