SILLY link error when /MD option is set in demo program
Posted: Wed Feb 23, 2011 05:31
I've static linked to CEGUI 0.7.5 in my own project and found that when /MD(Multi-threaded DLL) option is set, there will be many link errors,:
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
1>msvcprt.lib(MSVCP80.dll) : error LNK2005: "public: __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::~basic_string<char,struct std::char_traits<char>,class std::allocator<char> >(void)" (??1?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE@XZ) already defined in SILLY.lib(SILLYImageLoaderManager.obj)
1>msvcprt.lib(MSVCP80.dll) : error LNK2005: "public: __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >(char const *)" (??0?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE@PBD@Z) already defined in SILLY.lib(SILLYImageLoaderManager.obj)
1>msvcprt.lib(MSVCP80.dll) : error LNK2005: "public: __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" (??0?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE@ABV01@@Z) already defined in SILLY.lib(SILLYImageLoaderManager.obj)
1>msvcprt.lib(MSVCP80.dll) : error LNK2005: "public: char const * __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::c_str(void)const " (?c_str@?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QBEPBDXZ) already defined in SILLY.lib(SILLYImageLoaderManager.obj)
1>msvcprt.lib(MSVCP80.dll) : error LNK2005: "public: unsigned int __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::size(void)const " (?size@?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QBEIXZ) already defined in SILLY.lib(SILLYImageLoaderManager.obj)
1>LINK : warning LNK4098: defaultlib 'LIBCMT' conflicts with use of other libs; use /NODEFAULTLIB:library
1>SILLY.lib(SILLYPNGImageLoader.obj) : error LNK2019: unresolved external symbol _png_error referenced in function "void __cdecl SILLY::PNG_read_function(struct png_struct_def *,unsigned char *,unsigned int)" (?PNG_read_function@SILLY@@YAXPAUpng_struct_def@@PAEI@Z)
1>SILLY.lib(SILLYPNGImageLoader.obj) : error LNK2019: unresolved external symbol _png_get_io_ptr referenced in function "void __cdecl SILLY::PNG_read_function(struct png_struct_def *,unsigned char *,unsigned int)" (?PNG_read_function@SILLY@@YAXPAUpng_struct_def@@PAEI@Z)
1>SILLY.lib(SILLYPNGImageLoader.obj) : error LNK2019: unresolved external symbol _png_get_channels referenced in function "public: virtual class SILLY::ImageContext * __thiscall SILLY::PNGImageLoader::loadHeader(enum SILLY::PixelFormat &,class SILLY::DataSource *)" (?loadHeader@PNGImageLoader@SILLY@@UAEPAVImageContext@2@AAW4PixelFormat@2@PAVDataSource@2@@Z)
1>SILLY.lib(SILLYPNGImageLoader.obj) : error LNK2019: unresolved external symbol _png_get_bit_depth referenced in function "public: virtual class SILLY::ImageContext * __thiscall SILLY::PNGImageLoader::loadHeader(enum SILLY::PixelFormat &,class SILLY::DataSource *)" (?loadHeader@PNGImageLoader@SILLY@@UAEPAVImageContext@2@AAW4PixelFormat@2@PAVDataSource@2@@Z)
1>SILLY.lib(SILLYPNGImageLoader.obj) : error LNK2019: unresolved external symbol _png_read_png referenced in function "public: virtual class SILLY::ImageContext * __thiscall SILLY::PNGImageLoader::loadHeader(enum SILLY::PixelFormat &,class SILLY::DataSource *)" (?loadHeader@PNGImageLoader@SILLY@@UAEPAVImageContext@2@AAW4PixelFormat@2@PAVDataSource@2@@Z)
1>SILLY.lib(SILLYPNGImageLoader.obj) : error LNK2019: unresolved external symbol _png_set_read_fn referenced in function "public: virtual class SILLY::ImageContext * __thiscall SILLY::PNGImageLoader::loadHeader(enum SILLY::PixelFormat &,class SILLY::DataSource *)" (?loadHeader@PNGImageLoader@SILLY@@UAEPAVImageContext@2@AAW4PixelFormat@2@PAVDataSource@2@@Z)
1>SILLY.lib(SILLYPNGImageLoader.obj) : error LNK2019: unresolved external symbol _png_set_error_fn referenced in function "public: virtual class SILLY::ImageContext * __thiscall SILLY::PNGImageLoader::loadHeader(enum SILLY::PixelFormat &,class SILLY::DataSource *)" (?loadHeader@PNGImageLoader@SILLY@@UAEPAVImageContext@2@AAW4PixelFormat@2@PAVDataSource@2@@Z)
1>SILLY.lib(SILLYPNGImageLoader.obj) : error LNK2019: unresolved external symbol _png_set_longjmp_fn referenced in function "public: virtual class SILLY::ImageContext * __thiscall SILLY::PNGImageLoader::loadHeader(enum SILLY::PixelFormat &,class SILLY::DataSource *)" (?loadHeader@PNGImageLoader@SILLY@@UAEPAVImageContext@2@AAW4PixelFormat@2@PAVDataSource@2@@Z)
1>SILLY.lib(SILLYPNGImageLoader.obj) : error LNK2019: unresolved external symbol _png_create_info_struct referenced in function "public: virtual class SILLY::ImageContext * __thiscall SILLY::PNGImageLoader::loadHeader(enum SILLY::PixelFormat &,class SILLY::DataSource *)" (?loadHeader@PNGImageLoader@SILLY@@UAEPAVImageContext@2@AAW4PixelFormat@2@PAVDataSource@2@@Z)
1>SILLY.lib(SILLYPNGImageLoader.obj) : error LNK2019: unresolved external symbol _png_create_read_struct referenced in function "public: virtual class SILLY::ImageContext * __thiscall SILLY::PNGImageLoader::loadHeader(enum SILLY::PixelFormat &,class SILLY::DataSource *)" (?loadHeader@PNGImageLoader@SILLY@@UAEPAVImageContext@2@AAW4PixelFormat@2@PAVDataSource@2@@Z)
1>SILLY.lib(SILLYPNGImageLoader.obj) : error LNK2019: unresolved external symbol _png_get_rows referenced in function "public: virtual bool __thiscall SILLY::PNGImageLoader::loadImageData(enum SILLY::PixelOrigin,class SILLY::DataSource *,class SILLY::ImageContext *)" (?loadImageData@PNGImageLoader@SILLY@@UAE_NW4PixelOrigin@2@PAVDataSource@2@PAVImageContext@2@@Z)
1>SILLY.lib(SILLYPNGImageContext.obj) : error LNK2019: unresolved external symbol _png_destroy_read_struct referenced in function "public: virtual __thiscall SILLY::PNGImageContext::~PNGImageContext(void)" (??1PNGImageContext@SILLY@@UAE@XZ)
1>SILLY.lib(SILLYPNGImageContext.obj) : error LNK2019: unresolved external symbol _png_get_image_height referenced in function "private: void __thiscall SILLY::PNGImageContext::setImageSize(void)" (?setImageSize@PNGImageContext@SILLY@@AAEXXZ)
1>SILLY.lib(SILLYPNGImageContext.obj) : error LNK2019: unresolved external symbol _png_get_image_width referenced in function "private: void __thiscall SILLY::PNGImageContext::setImageSize(void)" (?setImageSize@PNGImageContext@SILLY@@AAEXXZ)
1>../../../../bin/Sample_Demo6_Static.exe : fatal error LNK1120: 14 unresolved externals
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
We know that runtime library in CEGUI 0.7.5 used /MT option, so I guess it is the SILLY.lib built as /MT set that caused the above link error.
Could you guys provide us some solution about this? I think many projects will set their runtime library to /MD.
And I also found that CEGUI 0.6.0 used /MD option, but CEGUI 0.7.5 changed it, why?
Thanks very much.
SHEN Hui.
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
1>msvcprt.lib(MSVCP80.dll) : error LNK2005: "public: __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::~basic_string<char,struct std::char_traits<char>,class std::allocator<char> >(void)" (??1?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE@XZ) already defined in SILLY.lib(SILLYImageLoaderManager.obj)
1>msvcprt.lib(MSVCP80.dll) : error LNK2005: "public: __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >(char const *)" (??0?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE@PBD@Z) already defined in SILLY.lib(SILLYImageLoaderManager.obj)
1>msvcprt.lib(MSVCP80.dll) : error LNK2005: "public: __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" (??0?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE@ABV01@@Z) already defined in SILLY.lib(SILLYImageLoaderManager.obj)
1>msvcprt.lib(MSVCP80.dll) : error LNK2005: "public: char const * __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::c_str(void)const " (?c_str@?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QBEPBDXZ) already defined in SILLY.lib(SILLYImageLoaderManager.obj)
1>msvcprt.lib(MSVCP80.dll) : error LNK2005: "public: unsigned int __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::size(void)const " (?size@?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QBEIXZ) already defined in SILLY.lib(SILLYImageLoaderManager.obj)
1>LINK : warning LNK4098: defaultlib 'LIBCMT' conflicts with use of other libs; use /NODEFAULTLIB:library
1>SILLY.lib(SILLYPNGImageLoader.obj) : error LNK2019: unresolved external symbol _png_error referenced in function "void __cdecl SILLY::PNG_read_function(struct png_struct_def *,unsigned char *,unsigned int)" (?PNG_read_function@SILLY@@YAXPAUpng_struct_def@@PAEI@Z)
1>SILLY.lib(SILLYPNGImageLoader.obj) : error LNK2019: unresolved external symbol _png_get_io_ptr referenced in function "void __cdecl SILLY::PNG_read_function(struct png_struct_def *,unsigned char *,unsigned int)" (?PNG_read_function@SILLY@@YAXPAUpng_struct_def@@PAEI@Z)
1>SILLY.lib(SILLYPNGImageLoader.obj) : error LNK2019: unresolved external symbol _png_get_channels referenced in function "public: virtual class SILLY::ImageContext * __thiscall SILLY::PNGImageLoader::loadHeader(enum SILLY::PixelFormat &,class SILLY::DataSource *)" (?loadHeader@PNGImageLoader@SILLY@@UAEPAVImageContext@2@AAW4PixelFormat@2@PAVDataSource@2@@Z)
1>SILLY.lib(SILLYPNGImageLoader.obj) : error LNK2019: unresolved external symbol _png_get_bit_depth referenced in function "public: virtual class SILLY::ImageContext * __thiscall SILLY::PNGImageLoader::loadHeader(enum SILLY::PixelFormat &,class SILLY::DataSource *)" (?loadHeader@PNGImageLoader@SILLY@@UAEPAVImageContext@2@AAW4PixelFormat@2@PAVDataSource@2@@Z)
1>SILLY.lib(SILLYPNGImageLoader.obj) : error LNK2019: unresolved external symbol _png_read_png referenced in function "public: virtual class SILLY::ImageContext * __thiscall SILLY::PNGImageLoader::loadHeader(enum SILLY::PixelFormat &,class SILLY::DataSource *)" (?loadHeader@PNGImageLoader@SILLY@@UAEPAVImageContext@2@AAW4PixelFormat@2@PAVDataSource@2@@Z)
1>SILLY.lib(SILLYPNGImageLoader.obj) : error LNK2019: unresolved external symbol _png_set_read_fn referenced in function "public: virtual class SILLY::ImageContext * __thiscall SILLY::PNGImageLoader::loadHeader(enum SILLY::PixelFormat &,class SILLY::DataSource *)" (?loadHeader@PNGImageLoader@SILLY@@UAEPAVImageContext@2@AAW4PixelFormat@2@PAVDataSource@2@@Z)
1>SILLY.lib(SILLYPNGImageLoader.obj) : error LNK2019: unresolved external symbol _png_set_error_fn referenced in function "public: virtual class SILLY::ImageContext * __thiscall SILLY::PNGImageLoader::loadHeader(enum SILLY::PixelFormat &,class SILLY::DataSource *)" (?loadHeader@PNGImageLoader@SILLY@@UAEPAVImageContext@2@AAW4PixelFormat@2@PAVDataSource@2@@Z)
1>SILLY.lib(SILLYPNGImageLoader.obj) : error LNK2019: unresolved external symbol _png_set_longjmp_fn referenced in function "public: virtual class SILLY::ImageContext * __thiscall SILLY::PNGImageLoader::loadHeader(enum SILLY::PixelFormat &,class SILLY::DataSource *)" (?loadHeader@PNGImageLoader@SILLY@@UAEPAVImageContext@2@AAW4PixelFormat@2@PAVDataSource@2@@Z)
1>SILLY.lib(SILLYPNGImageLoader.obj) : error LNK2019: unresolved external symbol _png_create_info_struct referenced in function "public: virtual class SILLY::ImageContext * __thiscall SILLY::PNGImageLoader::loadHeader(enum SILLY::PixelFormat &,class SILLY::DataSource *)" (?loadHeader@PNGImageLoader@SILLY@@UAEPAVImageContext@2@AAW4PixelFormat@2@PAVDataSource@2@@Z)
1>SILLY.lib(SILLYPNGImageLoader.obj) : error LNK2019: unresolved external symbol _png_create_read_struct referenced in function "public: virtual class SILLY::ImageContext * __thiscall SILLY::PNGImageLoader::loadHeader(enum SILLY::PixelFormat &,class SILLY::DataSource *)" (?loadHeader@PNGImageLoader@SILLY@@UAEPAVImageContext@2@AAW4PixelFormat@2@PAVDataSource@2@@Z)
1>SILLY.lib(SILLYPNGImageLoader.obj) : error LNK2019: unresolved external symbol _png_get_rows referenced in function "public: virtual bool __thiscall SILLY::PNGImageLoader::loadImageData(enum SILLY::PixelOrigin,class SILLY::DataSource *,class SILLY::ImageContext *)" (?loadImageData@PNGImageLoader@SILLY@@UAE_NW4PixelOrigin@2@PAVDataSource@2@PAVImageContext@2@@Z)
1>SILLY.lib(SILLYPNGImageContext.obj) : error LNK2019: unresolved external symbol _png_destroy_read_struct referenced in function "public: virtual __thiscall SILLY::PNGImageContext::~PNGImageContext(void)" (??1PNGImageContext@SILLY@@UAE@XZ)
1>SILLY.lib(SILLYPNGImageContext.obj) : error LNK2019: unresolved external symbol _png_get_image_height referenced in function "private: void __thiscall SILLY::PNGImageContext::setImageSize(void)" (?setImageSize@PNGImageContext@SILLY@@AAEXXZ)
1>SILLY.lib(SILLYPNGImageContext.obj) : error LNK2019: unresolved external symbol _png_get_image_width referenced in function "private: void __thiscall SILLY::PNGImageContext::setImageSize(void)" (?setImageSize@PNGImageContext@SILLY@@AAEXXZ)
1>../../../../bin/Sample_Demo6_Static.exe : fatal error LNK1120: 14 unresolved externals
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
We know that runtime library in CEGUI 0.7.5 used /MT option, so I guess it is the SILLY.lib built as /MT set that caused the above link error.
Could you guys provide us some solution about this? I think many projects will set their runtime library to /MD.
And I also found that CEGUI 0.6.0 used /MD option, but CEGUI 0.7.5 changed it, why?
Thanks very much.
SHEN Hui.