Lots of link errors in Debug but not realease build

B

Bruce

I am getting a lot of link errors when compiling in the debug build but
not release. I am compiling a CLR managed code class library.

I believe the link errors are actually being caused by a static library
of unmanagaed code.

I think the problem comes from the fact that the unmanaged static lib
uses the STL. Any idea how to fix this?




Below are the errors:

libcpmtd.lib(xlock.obj) : error LNK2005: "public: __thiscall
std::_Lockit::_Lockit(int)" (??0_Lockit@std@@QAE@H@Z) already defined in
msvcprtd.lib(MSVCP80D.dll)
libcpmtd.lib(xlock.obj) : error LNK2005: "public: __thiscall
std::_Lockit::~_Lockit(void)" (??1_Lockit@std@@QAE@XZ) already defined
in msvcprtd.lib(MSVCP80D.dll)
libcpmtd.lib(xdebug.obj) : error LNK2005: "void * __cdecl operator
new[](unsigned int,struct std::_DebugHeapTag_t const &,char *,int)"
(??_U@YAPAXIABU_DebugHeapTag_t@std@@PADH@Z) already defined in
msvcprtd.lib(MSVCP80D.dll)
libcpmtd.lib(xdebug.obj) : error LNK2005: "struct std::_DebugHeapTag_t
const & __cdecl std::_DebugHeapTag_func(void)"
(?_DebugHeapTag_func@std@@YAABU_DebugHeapTag_t@1@XZ) already defined in
msvcprtd.lib(MSVCP80D.dll)
LIBCMTD.lib(stdexcpt.obj) : error LNK2005: "public: __thiscall
std::exception::exception(void)" (??0exception@std@@QAE@XZ) already
defined in MSVCRTD.lib(MSVCR80D.dll)
LIBCMTD.lib(stdexcpt.obj) : error LNK2005: "public: __thiscall
std::exception::exception(char const * const &)"
(??0exception@std@@QAE@ABQBD@Z) already defined in MSVCRTD.lib(MSVCR80D.dll)
LIBCMTD.lib(stdexcpt.obj) : error LNK2005: "public: __thiscall
std::exception::exception(class std::exception const &)"
(??0exception@std@@QAE@ABV01@@Z) already defined in
MSVCRTD.lib(MSVCR80D.dll)
LIBCMTD.lib(stdexcpt.obj) : error LNK2005: "public: virtual __thiscall
std::exception::~exception(void)" (??1exception@std@@UAE@XZ) already
defined in MSVCRTD.lib(MSVCR80D.dll)
LIBCMTD.lib(stdexcpt.obj) : error LNK2005: "public: virtual char const *
__thiscall std::exception::what(void)const "
(?what@exception@std@@UBEPBDXZ) already defined in MSVCRTD.lib(MSVCR80D.dll)
LIBCMTD.lib(dbgheap.obj) : error LNK2005: _malloc already defined in
MSVCRTD.lib(MSVCR80D.dll)
LIBCMTD.lib(dbgheap.obj) : error LNK2005: __malloc_dbg already defined
in MSVCRTD.lib(MSVCR80D.dll)
LIBCMTD.lib(dbgheap.obj) : error LNK2005: _realloc already defined in
MSVCRTD.lib(MSVCR80D.dll)
LIBCMTD.lib(dbgheap.obj) : error LNK2005: _free already defined in
MSVCRTD.lib(MSVCR80D.dll)
LIBCMTD.lib(dbgheap.obj) : error LNK2005: __free_dbg already defined in
MSVCRTD.lib(MSVCR80D.dll)
LIBCMTD.lib(dbgheap.obj) : error LNK2005: __CrtSetCheckCount already
defined in MSVCRTD.lib(MSVCR80D.dll)
LIBCMTD.lib(crt0dat.obj) : error LNK2005: __amsg_exit already defined in
MSVCRTD.lib(MSVCR80D.dll)
LIBCMTD.lib(crt0dat.obj) : error LNK2005: __initterm_e already defined
in MSVCRTD.lib(MSVCR80D.dll)
LIBCMTD.lib(tidtable.obj) : error LNK2005: __encode_pointer already
defined in MSVCRTD.lib(MSVCR80D.dll)
LIBCMTD.lib(tidtable.obj) : error LNK2005: __encoded_null already
defined in MSVCRTD.lib(MSVCR80D.dll)
LIBCMTD.lib(tidtable.obj) : error LNK2005: __decode_pointer already
defined in MSVCRTD.lib(MSVCR80D.dll)
LIBCMTD.lib(invarg.obj) : error LNK2005: __invalid_parameter already
defined in MSVCRTD.lib(MSVCR80D.dll)
LIBCMTD.lib(dbghook.obj) : error LNK2005: __crt_debugger_hook already
defined in MSVCRTD.lib(MSVCR80D.dll)
LIBCMTD.lib(sprintf.obj) : error LNK2005: _sprintf already defined in
MSVCRTD.lib(MSVCR80D.dll)
LIBCMTD.lib(crt0init.obj) : error LNK2005: ___xi_a already defined in
MSVCRTD.lib(cinitexe.obj)
LIBCMTD.lib(crt0init.obj) : error LNK2005: ___xi_z already defined in
MSVCRTD.lib(cinitexe.obj)
LIBCMTD.lib(crt0init.obj) : error LNK2005: ___xc_a already defined in
MSVCRTD.lib(cinitexe.obj)
LIBCMTD.lib(crt0init.obj) : error LNK2005: ___xc_z already defined in
MSVCRTD.lib(cinitexe.obj)
LIBCMTD.lib(hooks.obj) : error LNK2005: "void __cdecl terminate(void)"
(?terminate@@YAXXZ) already defined in MSVCRTD.lib(MSVCR80D.dll)
LIBCMTD.lib(winxfltr.obj) : error LNK2005: ___CppXcptFilter already
defined in MSVCRTD.lib(MSVCR80D.dll)
LIBCMTD.lib(mlock.obj) : error LNK2005: __lock already defined in
MSVCRTD.lib(MSVCR80D.dll)
LIBCMTD.lib(mlock.obj) : error LNK2005: __unlock already defined in
MSVCRTD.lib(MSVCR80D.dll)
LIBCMTD.lib(dbgrptw.obj) : error LNK2005: __CrtDbgReportW already
defined in MSVCRTD.lib(MSVCR80D.dll)
Creating library D:\Data\GarXfaceNET\bin\GarXfaceNet.lib and object
D:\Data\GarXfaceNET\bin\GarXfaceNet.exp
LINK : warning LNK4098: defaultlib 'MSVCRTD' conflicts with use of other
libs; use /NODEFAULTLIB:library
LINK : warning LNK4098: defaultlib 'LIBCMTD' conflicts with use of other
libs; use /NODEFAULTLIB:library
 
D

David Lowndes

libcpmtd.lib(xlock.obj) : error LNK2005: "public: __thiscall
std::_Lockit::_Lockit(int)" (??0_Lockit@std@@QAE@H@Z) already defined in
msvcprtd.lib(MSVCP80D.dll)

You appear to have some components built to use the static linked 'C'
run-time and others using the DLL run-time. Ensure they're all built
with the same options (as your release build must be) and that should
resolve the problem.

Dave
 
B

Bruce

David said:
You appear to have some components built to use the static linked 'C'
run-time and others using the DLL run-time. Ensure they're all built
with the same options (as your release build must be) and that should
resolve the problem.

Dave

Thanks Dave,

What I did was to copy my Release build and slowly started changing it
into a Debug build. All I did was to change the Whole Program
Optimization to No and this caused the link errors.


Why would this setting cause the link errors?

Bruce
 
D

David Lowndes

Thanks Dave,

What I did was to copy my Release build and slowly started changing it
into a Debug build. All I did was to change the Whole Program
Optimization to No and this caused the link errors.


Why would this setting cause the link errors?

I don't know Bruce.

Have you got some other library that you're pulling in that's built
with other options?

Dave
 
B

Bruce

David said:
I don't know Bruce.

Have you got some other library that you're pulling in that's built
with other options?

Dave


Only one (other than the standard libraries) of my own creation. When I
copied the release build and modified the one setting, I did not change
to another build of the lib of my static lib. I kept the same lib.

All I changed was the one setting mentioned. Does even the Optimization
settings need to match?

Bruce
 
D

David Lowndes

Have you got some other library that you're pulling in that's built
Only one (other than the standard libraries) of my own creation. When I
copied the release build and modified the one setting, I did not change
to another build of the lib of my static lib. I kept the same lib.

You will (most likely) need to rebuild that lib to use the same 'C'
run-time library settings as your debug build.
All I changed was the one setting mentioned. Does even the Optimization
settings need to match?

No, I don't think the optimization will make any difference. The key
points are that your project and the static library project you're
linking with should both be built with the same 'C' run-time library
settings.

Dave
 

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