By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
429,053 Members | 1,615 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 429,053 IT Pros & Developers. It's quick & easy.

Linking problems in debug mode

100+
P: 105
Hi all,

I am getting linking errors when I run my program in debug mode and the same thing I run in release mode it doesnt show errors..Am I linking wrong libraries in the debug mode?Can they be different from the release mode?

LIBCMT.lib(invarg.obj) : error LNK2005: __initp_misc_invarg already defined in LIBCMTD.lib(invarg.obj)
1>LIBCMT.lib(invarg.obj) : error LNK2005: __invoke_watson already defined in LIBCMTD.lib(invarg.obj)
1>LIBCMT.lib(invarg.obj) : error LNK2005: __set_invalid_parameter_handler already defined in LIBCMTD.lib(invarg.obj)
1>LIBCMT.lib(invarg.obj) : error LNK2005: __get_invalid_parameter_handler already defined in LIBCMTD.lib(invarg.obj)
1>LIBCMT.lib(invarg.obj) : error LNK2005: "void __cdecl _invoke_watson(unsigned short const *,unsigned short const *,unsigned short const *,unsigned int,unsigned int)" (?_invoke_watson@@YAXPBG00II@Z) already defined in LIBCMTD.lib(invarg.obj)
1>LIBCMT.lib(invarg.obj) : error LNK2005: __invalid_parameter already defined in LIBCMTD.lib(invarg.obj)
1>LIBCMT.lib(invarg.obj) : error LNK2005: "void __cdecl _invalid_parameter(unsigned short const *,unsigned short const *,unsigned short const *,unsigned int,unsigned int)" (?_invalid_parameter@@YAXPBG00II@Z) already defined in LIBCMTD.lib(invarg.obj)
1>LIBCMT.lib(invarg.obj) : error LNK2005: ___pInvalidArgHandler already defined in LIBCMTD.lib(invarg.obj)
1>LINK : warning LNK4098: defaultlib 'LIBCMT' conflicts with use of other libs; use /NODEFAULTLIB:library
1>D:\assignemnts\testing\Debug\testing.exe : fatal error LNK1169: one or more multiply defined symbols found


Thanks
May 2 '07 #1
Share this Question
Share on Google+
4 Replies


100+
P: 256
This is just a guess...
LIBCMT.lib(invarg.obj) : error LNK2005: __initp_misc_invarg already defined in LIBCMTD.lib(invarg.obj)
It looks like you have 2 sets of each library (one with a 'D' probably for debug mode and one without) so thats why everything says "already defined"
1>LINK : warning LNK4098: defaultlib 'LIBCMT' conflicts with use of other libs; use /NODEFAULTLIB:library
This error message looks like a hint on how to resolve the issue. Try supplying /NODEFAULTLIB:LIBCMT (or maybe LIBCMTD) to your compiler. If that does no good poke around at your build instructions or settings (or whatever) and see whats different when you use debug mode.

Linker errors can be non-trivial to resolve, maybe provide some more details about what compiler your using and what options are being given to it.
May 2 '07 #2

Banfa
Expert Mod 5K+
P: 8,916
This is just a guess...
It's a good guess because it is pretty much spot on.

You have compiled some of your files in release mode so they have the default library LIBCMT.lib (library c run time multithreaded) embedded as there default library to link with. Some of your other files files have got library LIBCMTD.lib (library c run time multithreaded debug) embedded as the library to link with. Since this is the release and debug version of the same library the same function exist in both.

If you can look in your compiler settings for the Standard Library/C run time, check that in the debug build all the libraries are set to the multi threaded debug option.

If not change you linker settings for the debug build to remove LIBCMT.LIB as a default library for the debug link.
May 2 '07 #3

100+
P: 105
I tried to change the settings still getting the same errors.

In case if I change the lib files for the debug mode , I get this warning:

LINK : warning LNK4075: ignoring '/INCREMENTAL' due to '/LTCG' specification
LINK : /LTCG specified but no code generation required; remove /LTCG from the link command line to improve linker performance

It does generate .exe file but causes an exception.

I am not ablt to understand what this warning is???
May 3 '07 #4

100+
P: 105
I have changed the lib files for the debug mode and now I am able to build in the debug mode.

Thanks to all who helped me out.
May 4 '07 #5

Post your reply

Sign in to post your reply or Sign up for a free account.