加载了CxImage类以后,编译能通过,连接的时候报错。我就想简单测试一下看能否使用,如下代码:
#include<iostream>
#include "ximage.h"
int main()
{
CxImage image;
image.Load("lena.bmp",CXIMAGE_FORMAT_BMP);
return 0;
}
连接出现如下四个错误:
Linking...
try.obj : error LNK2001: unresolved external symbol "public: bool __thiscall CxImage::Load(char const *,unsigned long)" (?Load@CxImage@@QAE_NPBDK@Z)
try.obj : error LNK2001: unresolved external symbol "public: __thiscall CxImage::CxImage(unsigned long)" (??0CxImage@@QAE@K@Z)
try.obj : error LNK2001: unresolved external symbol "public: bool __thiscall CxImage::Destroy(void)" (?Destroy@CxImage@@QAE_NXZ)
Debug/try.exe : fatal error LNK1120: 3 unresolved externals
Error executing link.exe.
try.exe - 4 error(s), 0 warning(s)
请问是哪里出了问题,是不是哪里没有设置好,还是稳健还没有配置好啊 ??
谢谢了

解决方案 »

  1.   

    你工程里是不是没有包含CxImage 类的实现?
    如果是dll的话,要在工程里包含这个dll
      

  2.   

       这里面不是用的dll,而是一些lib文件,以及相关的头文件我已经加到同一个文件夹中了。
      

  3.   

    加入#pragma comment(lib,"***.lib")
    在VS2008以上的版本Linker->General->Additional Include Directories
    这个最好指定一下
      

  4.   

    今天发现微软提供的一个CImage类,很好用。你可以试试MS的这个类用用。
      

  5.   

    我用vc6.0 Additional Include Directories也指定了,还是有错。在project-not use MFC的情况下报下面的错:
    LINK : warning LNK4098: defaultlib "LIBCMT" conflicts with use of other libs; use /NODEFAULTLIB:library
    try.obj : error LNK2001: unresolved external symbol "public: bool __thiscall CxImage::Load(char const *,unsigned long)" (?Load@CxImage@@QAE_NPBDK@Z)
    Debug/try.exe : fatal error LNK1120: 1 unresolved externals
    Load有问题,是不是哪里还有个什么文件没有弄过去,但是我看了下,好像又没有少什么文件了。
      

  6.   

    VC 6.0的话得在Project -> Setting -> link 里的lib module库模块里面填上这个lib库