在实验室编译前人程序时,发现如下诸多与CxImage类相关的LINK错误,实在搞不懂。还请各位牛人指点。
FMTProjectDoc.obj : error LNK2001: unresolved external symbol "public: char const * __thiscall CxImage::GetLastError(void)" (?GetLastError@CxImage@@QAEPBDXZ)
FMTProjectDoc.obj : error LNK2001: unresolved external symbol "public: bool __thiscall CxImage::IsValid(void)const " (?IsValid@CxImage@@QBE_NXZ)
FMTProjectDoc.obj : error LNK2001: unresolved external symbol "public: __thiscall CxImage::CxImage(char const *,unsigned long)" (??0CxImage@@QAE@PBDK@Z)
FMTProjectDoc.obj : error LNK2001: unresolved external symbol "public: bool __thiscall CxImage::Save(char const *,unsigned long)" (?Save@CxImage@@QAE_NPBDK@Z)
FMTProjectDoc.obj : error LNK2001: unresolved external symbol "public: unsigned short __thiscall CxImage::GetBpp(void)const " (?GetBpp@CxImage@@QBEGXZ)
FMTProjectDoc.obj : error LNK2001: unresolved external symbol "public: unsigned long __thiscall CxImage::GetType(void)const " (?GetType@CxImage@@QBEKXZ)
FMTProjectDoc.obj : error LNK2001: unresolved external symbol "public: bool __thiscall CxImage::Transfer(class CxImage &)" (?Transfer@CxImage@@QAE_NAAV1@@Z)
FMTProjectDoc.obj : error LNK2001: unresolved external symbol "public: bool __thiscall CxImage::CreateFromHBITMAP(struct HBITMAP__ *,struct HPALETTE__ *)" (?CreateFromHBITMAP@CxImage@@QAE_NPAUHBITMAP__@@PAUHPALETTE__@@@Z)
FMTProjectDoc.obj : error LNK2001: unresolved external symbol "public: __thiscall CxImage::CxImage(unsigned long)" (??0CxImage@@QAE@K@Z)
FMTProjectDoc.obj : error LNK2001: unresolved external symbol "public: long __thiscall CxImage::Draw(struct HDC__ *,long,long,long,long,struct tagRECT *,bool)" (?Draw@CxImage@@QAEJPAUHDC__@@JJJJPAUtagRECT@@_N@Z)
FMTProjectView.obj : error LNK2001: unresolved external symbol "public: long __thiscall CxImage::Draw(struct HDC__ *,long,long,long,long,struct tagRECT *,bool)" (?Draw@CxImage@@QAEJPAUHDC__@@JJJJPAUtagRECT@@_N@Z)
FMTProjectDoc.obj : error LNK2001: unresolved external symbol "public: unsigned long __thiscall CxImage::GetWidth(void)const " (?GetWidth@CxImage@@QBEKXZ)
FMTProjectDoc.obj : error LNK2001: unresolved external symbol "public: unsigned long __thiscall CxImage::GetHeight(void)const " (?GetHeight@CxImage@@QBEKXZ)
FMTProjectDoc.obj : error LNK2001: unresolved external symbol "public: void __thiscall CxImage::SetPaletteColor(unsigned char,struct tagRGBQUAD)" (?SetPaletteColor@CxImage@@QAEXEUtagRGBQUAD@@@Z)
FMTProjectDoc.obj : error LNK2001: unresolved external symbol "public: bool __thiscall CxImage::GrayScale(void)" (?GrayScale@CxImage@@QAE_NXZ)
FMTProjectDoc.obj : error LNK2001: unresolved external symbol "public: bool __thiscall CxImage::IsGrayScale(void)" (?IsGrayScale@CxImage@@QAE_NXZ)
FMTProjectDoc.obj : error LNK2001: unresolved external symbol "public: bool __thiscall CxImage::Destroy(void)" (?Destroy@CxImage@@QAE_NXZ)
FMTProjectDoc.obj : error LNK2001: unresolved external symbol "public: float __thiscall CxImage::Mean(void)" (?Mean@CxImage@@QAEMXZ)
FMTProjectDoc.obj : error LNK2001: unresolved external symbol "public: void __thiscall CxImage::Copy(class CxImage const &,bool,bool,bool)" (?Copy@CxImage@@QAEXABV1@_N11@Z)
FMTProjectDoc.obj : error LNK2001: unresolved external symbol "public: char const * __thiscall CxImage::GetLastError(void)" (?GetLastError@CxImage@@QAEPBDXZ)
FMTProjectDoc.obj : error LNK2001: unresolved external symbol "public: bool __thiscall CxImage::IsValid(void)const " (?IsValid@CxImage@@QBE_NXZ)
FMTProjectDoc.obj : error LNK2001: unresolved external symbol "public: __thiscall CxImage::CxImage(char const *,unsigned long)" (??0CxImage@@QAE@PBDK@Z)
FMTProjectDoc.obj : error LNK2001: unresolved external symbol "public: bool __thiscall CxImage::Save(char const *,unsigned long)" (?Save@CxImage@@QAE_NPBDK@Z)
FMTProjectDoc.obj : error LNK2001: unresolved external symbol "public: unsigned short __thiscall CxImage::GetBpp(void)const " (?GetBpp@CxImage@@QBEGXZ)
FMTProjectDoc.obj : error LNK2001: unresolved external symbol "public: unsigned long __thiscall CxImage::GetType(void)const " (?GetType@CxImage@@QBEKXZ)
FMTProjectDoc.obj : error LNK2001: unresolved external symbol "public: bool __thiscall CxImage::Transfer(class CxImage &)" (?Transfer@CxImage@@QAE_NAAV1@@Z)
FMTProjectDoc.obj : error LNK2001: unresolved external symbol "public: bool __thiscall CxImage::CreateFromHBITMAP(struct HBITMAP__ *,struct HPALETTE__ *)" (?CreateFromHBITMAP@CxImage@@QAE_NPAUHBITMAP__@@PAUHPALETTE__@@@Z)
FMTProjectDoc.obj : error LNK2001: unresolved external symbol "public: __thiscall CxImage::CxImage(unsigned long)" (??0CxImage@@QAE@K@Z)
FMTProjectDoc.obj : error LNK2001: unresolved external symbol "public: long __thiscall CxImage::Draw(struct HDC__ *,long,long,long,long,struct tagRECT *,bool)" (?Draw@CxImage@@QAEJPAUHDC__@@JJJJPAUtagRECT@@_N@Z)
FMTProjectView.obj : error LNK2001: unresolved external symbol "public: long __thiscall CxImage::Draw(struct HDC__ *,long,long,long,long,struct tagRECT *,bool)" (?Draw@CxImage@@QAEJPAUHDC__@@JJJJPAUtagRECT@@_N@Z)
FMTProjectDoc.obj : error LNK2001: unresolved external symbol "public: unsigned long __thiscall CxImage::GetWidth(void)const " (?GetWidth@CxImage@@QBEKXZ)
FMTProjectDoc.obj : error LNK2001: unresolved external symbol "public: unsigned long __thiscall CxImage::GetHeight(void)const " (?GetHeight@CxImage@@QBEKXZ)
FMTProjectDoc.obj : error LNK2001: unresolved external symbol "public: void __thiscall CxImage::SetPaletteColor(unsigned char,struct tagRGBQUAD)" (?SetPaletteColor@CxImage@@QAEXEUtagRGBQUAD@@@Z)
FMTProjectDoc.obj : error LNK2001: unresolved external symbol "public: bool __thiscall CxImage::GrayScale(void)" (?GrayScale@CxImage@@QAE_NXZ)
FMTProjectDoc.obj : error LNK2001: unresolved external symbol "public: bool __thiscall CxImage::IsGrayScale(void)" (?IsGrayScale@CxImage@@QAE_NXZ)
FMTProjectDoc.obj : error LNK2001: unresolved external symbol "public: bool __thiscall CxImage::Destroy(void)" (?Destroy@CxImage@@QAE_NXZ)
FMTProjectDoc.obj : error LNK2001: unresolved external symbol "public: float __thiscall CxImage::Mean(void)" (?Mean@CxImage@@QAEMXZ)
FMTProjectDoc.obj : error LNK2001: unresolved external symbol "public: void __thiscall CxImage::Copy(class CxImage const &,bool,bool,bool)" (?Copy@CxImage@@QAEXABV1@_N11@Z)
或者路径不对、或者此lib文件不存在了。
但是紧接着又有如下link错误:
MSVCRTD.lib(MSVCRTD.dll) : error LNK2005: _fclose already defined in libcd.lib(fclose.obj)
MSVCRTD.lib(MSVCRTD.dll) : error LNK2005: _fflush already defined in libcd.lib(fflush.obj)
MSVCRTD.lib(MSVCRTD.dll) : error LNK2005: _floor already defined in libcd.lib(floor.obj)
MSVCRTD.lib(MSVCRTD.dll) : error LNK2005: _free already defined in libcd.lib(dbgheap.obj)
MSVCRTD.lib(MSVCRTD.dll) : error LNK2005: _malloc already defined in libcd.lib(dbgheap.obj)
MSVCRTD.lib(MSVCRTD.dll) : error LNK2005: _calloc already defined in libcd.lib(dbgheap.obj)
MSVCRTD.lib(MSVCRTD.dll) : error LNK2005: __mbsnbcpy already defined in libcd.lib(mbsnbcpy.obj)
MSVCRTD.lib(MSVCRTD.dll) : error LNK2005: _sprintf already defined in libcd.lib(sprintf.obj)
MSVCRTD.lib(MSVCRTD.dll) : error LNK2005: _ceil already defined in libcd.lib(ceil.obj)
MSVCRTD.lib(MSVCRTD.dll) : error LNK2005: _realloc already defined in libcd.lib(dbgheap.obj)
MSVCRTD.lib(MSVCRTD.dll) : error LNK2005: _printf already defined in libcd.lib(printf.obj)
MSVCRTD.lib(MSVCRTD.dll) : error LNK2005: _strncpy already defined in libcd.lib(strncpy.obj)
MSVCRTD.lib(MSVCRTD.dll) : error LNK2005: _strncmp already defined in libcd.lib(strncmp.obj)
MSVCRTD.lib(MSVCRTD.dll) : warning LNK4006: _fclose already defined in libcd.lib(fclose.obj); second definition ignored
MSVCRTD.lib(MSVCRTD.dll) : warning LNK4006: _fflush already defined in libcd.lib(fflush.obj); second definition ignored
MSVCRTD.lib(MSVCRTD.dll) : warning LNK4006: _floor already defined in libcd.lib(floor.obj); second definition ignored
MSVCRTD.lib(MSVCRTD.dll) : warning LNK4006: _free already defined in libcd.lib(dbgheap.obj); second definition ignored不知如何是好…… 还望牛人指点。
你看一下CXimage的另外一种方法,就是CXimage里面的DemoDLL这个例子,很简单的就配置成功了
因为引入lib库不像引入dll那样,lib库的编译方式必须和你的程序一样,还有debug版和release版好像也不能混用,而且不同的vc版本的库也可能有问题,例如vc6编的库,vc7使得时候都要处理一下才行。挺麻烦的。