473,386 Members | 1,699 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Lots of link errors in Debug but not realease build

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@X Z) 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

--
Bruce E. Stemplewski
GarXface OCX and C++ Class Library for the Garmin GPS
www.stempsoft.com
Dec 27 '06 #1
5 4673
>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
Dec 27 '06 #2
David Lowndes wrote:
>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
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
--
Bruce E. Stemplewski
GarXface OCX and C++ Class Library for the Garmin GPS
www.stempsoft.com
Dec 27 '06 #3
On Wed, 27 Dec 2006 10:07:09 -0500, Bruce <Br***@nospam.comwrote:
>David Lowndes wrote:
>>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

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
Dec 27 '06 #4
David Lowndes wrote:
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

--
Bruce E. Stemplewski
GarXface OCX and C++ Class Library for the Garmin GPS
www.stempsoft.com
Dec 27 '06 #5
>Have you got some other library that you're pulling in that's built
>with other options?

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
Dec 27 '06 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Xiaofeng Zhang | last post by:
when I compile my project setting, there are many LINK errors. But when I compile my project under debug setting, everything is OK. How can I deal with it? The errors is followed. Linking......
0
by: TGF | last post by:
Hello, I am creating a console app. I try to link a static library by including it in the Linker-Input-Additional Dependencies field under the Project properties. Then I specify the path to...
10
by: Douglas Buchanan | last post by:
I am using the following code instead of a very lengthly select case statement. (I have a lot of lookup tables in a settings form that are selected from a ListBox. The data adapters are given a...
10
by: Gary Hughes | last post by:
I'm getting the following error when attempting to link a managed C++ dll. I can't find any reference to these errors with google. Can anyone help? I've included the class definition causing the...
1
by: Claire | last post by:
I have a project that uses TChart assembly. I don't think that the assembly's the problem though. If I compile in debug mode with CopyLocal set to true, the solution builds perfectly. In Release...
3
by: Leith Bade | last post by:
I have been trying to use the new Visual C++ Toolkit 2003 with the VC6 IDE I set up the executable, inlcude, and library directories to point to the new compilers I had to fix a few errors in the...
10
by: Ian Lazarus | last post by:
Hello. How do "unresolved token" link errors occur. How do I fix them? Linking... LINK : error LNK2020: unresolved token (0A000015) ??_7type_info@@6B@ LINK : error LNK2020: unresolved token...
1
yabansu
by: yabansu | last post by:
Hi all, I implemented a basic client application. It communicates with server and works properly. Building processes succeed just by giving the following warning: LINK : D:\DOC\Visual Studio...
3
by: bowser | last post by:
Hello, I'm using g++ over eclipse in a mac os x. I'm new to all these technologies. I created a dylib, and to test it I made another project that links to it, but the compiler tells me that it...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.