build - Visual Studio - error LNK2005 in debug mode -
i'm integrating 3rd party code mfc app under visual studio 2010.
when in debug mode following build error occurs:
1>libcmt.lib(invarg.obj) : error lnk2005: __initp_misc_invarg defined in libcmtd.lib(invarg.obj) 1>libcmt.lib(invarg.obj) : error lnk2005: __call_reportfault defined in libcmtd.lib(invarg.obj) 1>libcmt.lib(invarg.obj) : error lnk2005: __set_invalid_parameter_handler defined in libcmtd.lib(invarg.obj) 1>libcmt.lib(invarg.obj) : error lnk2005: __get_invalid_parameter_handler defined in libcmtd.lib(invarg.obj) 1>libcmt.lib(invarg.obj) : error lnk2005: __invoke_watson 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) defined in libcmtd.lib(invarg.obj) 1>libcmt.lib(invarg.obj) : error lnk2005: __invalid_parameter 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) defined in libcmtd.lib(invarg.obj) 1>libcmt.lib(invarg.obj) : error lnk2005: ___pinvalidarghandler defined in libcmtd.lib(invarg.obj) 1>link : warning lnk4098: defaultlib 'libcmt' conflicts use of other libs; use /nodefaultlib:library 1>d:\my documents\dev\myproject\myproject\debug\myproject.exe : fatal error lnk1169: 1 or more multiply defined symbols found
using this advice able complete build in 2 ways:
- in release mode
- in debug mode using /force:multiple additional linker command line option
in second case (debug mode) many warnings still reported. if add /nodefaultlib:libcmt of them gone.
what cause of this?
how can solve this, instead of working around it?
for reason, you're linking against both libcmt , libcmtd (the debug version). (from reading end of each error line: already defined in libcmtd.lib(invarg.obj)
)
you're fixing right thing saying /nodefaultlib:libcmt. debug/release flag on third-party library you're linking against match debug/release mode on app build? guess third-party code pulling in redundant library somehow.
Comments
Post a Comment