Library causing lnk errors

Hello Everyone,

So I am trying to use the library IccProfLib.lib from color.org. They give you the source so I compiled it in VS2008 in release and everything seemed to work fine. I then start to write my program that will be using it. So I added the include directories and the library to the dependency list. So I #include "IccProfile.h" and create a CIccProfile object, I then compile the program in debug just to make sure everything is set up correctly. I got these linker errors.

Error	7	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)	LIBCMT.lib
Error	5	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)	LIBCMT.lib
Error	8	error LNK2005: ___pInvalidArgHandler already defined in LIBCMTD.lib(invarg.obj)	LIBCMT.lib
Error	4	error LNK2005: __get_invalid_parameter_handler already defined in LIBCMTD.lib(invarg.obj)	LIBCMT.lib
Error	1	error LNK2005: __initp_misc_invarg already defined in LIBCMTD.lib(invarg.obj)	LIBCMT.lib
Error	6	error LNK2005: __invalid_parameter already defined in LIBCMTD.lib(invarg.obj)	LIBCMT.lib
Error	2	error LNK2005: __invoke_watson already defined in LIBCMTD.lib(invarg.obj)	LIBCMT.lib
Error	3	error LNK2005: __set_invalid_parameter_handler already defined in LIBCMTD.lib(invarg.obj)	LIBCMT.lib
Error	10	fatal error LNK1169: one or more multiply defined symbols found	C:\Users\finnp\Desktop\testers\iccHeaderReader\Debug\iccHeaderReader.exe	1


I did some Google-fu and it seems this problem is caused because the IccProfLib.lib is including a library that is already included. So I tried to force everything to play nice via the command line using /FORCE:MULTIPLE. Well that did not work, and I expected it to fail but miracles can happen.

I then read that it could be IccProfLib.lib only used release libraries so you can only compile stuff in release. That did not work.

Next I tried to use /NODEFAULTLIB:LIBCMTD to try and remove the debug library so that it would just use LIBCMT. The errors I got were:

Error	1	error LNK2005: "public: static unsigned int __cdecl std::char_traits<char>::length(char const *)" (?length@?$char_traits@D@std@@SAIPBD@Z) already defined in IccProfLib.lib(IccProfile.obj)	msvcprt.lib
Error	2	fatal error LNK1169: one or more multiply defined symbols found	C:\Users\finnp\Desktop\testers\iccHeaderReader\Release\iccHeaderReader.exe

I looked in IccProfile.h and IccProfile.cpp for the function std::char_traits<char>::length(char const *) because that was the one causing a error and I could not find any function called length.

Anyway, next I then tried to remove msvcprt and got a whole lot of linker errors.

When I tried to remove LIBCMTD I got the following errors:

Error	3	error LNK2001: unresolved external symbol __CrtDbgReportW	libcpmtd.lib
Error	6	error LNK2019: unresolved external symbol __calloc_dbg referenced in function __Getctype	libcpmtd.lib
Error	2	error LNK2019: unresolved external symbol __CrtDbgReportW referenced in function "public: char const & __thiscall std::_String_const_iterator<char,struct std::char_traits<char>,class std::allocator<char> >::operator*(void)const " (??D?$_String_const_iterator@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QBEABDXZ)	libcpmtd.lib
Error	5	error LNK2019: unresolved external symbol __free_dbg referenced in function "void __cdecl operator delete(void *,struct std::_DebugHeapTag_t const &,char *,int)" (??3@YAXPAXABU_DebugHeapTag_t@std@@PADH@Z)	libcpmtd.lib
Error	4	error LNK2019: unresolved external symbol __malloc_dbg referenced in function "void * __cdecl operator new(unsigned int,struct std::_DebugHeapTag_t const &,char *,int)" (??2@YAPAXIABU_DebugHeapTag_t@std@@PADH@Z)	libcpmtd.lib
Error	7	fatal error LNK1120: 4 unresolved externals	C:\Users\finnp\Desktop\testers\iccHeaderReader\Debug\iccHeaderReader.exe
Warning	1	warning LNK4098: defaultlib 'LIBCMT' conflicts with use of other libs; use /NODEFAULTLIB:library	iccHeaderReader


Basically, I am running out of ideas and could use some help. If anyone has any ideas please post them.

Thanks,
- Mastion




You seem to have your library compiled with CRT statically (/MT) while your project uses CRT dinamically (/MD). Please try to fix it.
Topic archived. No new replies allowed.