testNewImageDlg.obj : error LNK2019: unresolved external symbol _OleLoadPicture referenced in function "protected: void __thiscall CTestNewImageDlg::OnButton1(void)" (?OnButton1@CTestNewImageDlg@@IAEXXZ)
emulatorDbg/testNewImage.exe : fatal error LNK1120: 1 unresolved externals

解决方案 »

  1.   

    导致 LNK2019 的常见问题有: 
    符号声明包含拼写错误,以致于符号声明与符号定义不同。 
    使用了一个函数,但其参数的类型或数量与函数定义不匹配。 
    函数声明使用和函数定义使用中的调用约定(__cdecl、__stdcall 或 __fastcall)不同。 
    符号定义在编译为 C 程序的文件中,而符号是在 C++ 文件中不带 extern "C" 修饰符声明的。在此情况下,请修改声明,例如不是使用: 
    extern int i;
    extern void g();
    而使用: 
    extern "C" int i;
    extern "C" void g();
    同样,如果在将由 C 程序使用的 C++ 文件中定义符号,请在定义中使用 extern "C"。 
    符号定义为静态,但稍后在文件外部被引用。 
    没有定义静态类成员。例如,应单独定义下面类声明中的成员变量 si: 
    #include <stdio.h>
    struct X {
       static int si;
    };// int X::si = 0;   // uncomment this line to resolvevoid main()
    {
       X *px = new X[2];
       printf("\n%d",px[0].si);   // LNK2019
    }
    也可能由于为 Visual Studio .NET 2003 进行的一致性工作生成此错误:模板友元和专用化。在 Visual Studio .NET 2003 中,必须定义声明新的非模板函数的友元声明。
    要使代码在 Visual C++ 的 Visual Studio .NET 2003 和 Visual Studio .NET 版本中均有效,请显式指定友元函数的模板参数列表。
    // LNK2019.cpp
    // LNK2019 expected
    template<class T>
    void f(T)
    {
    }template<class T>
    struct S
    {
       friend void f(T);
       // Try the folowing line instead:
       // friend void f<T>(T);
    };int main()
    {
       S<int> s;
       f(1);   // unresolved external
    }
      

  2.   

    这是我的代码:
      
          ::AfxOleInit();
    IPicture *pPic; 
        IStream *pStm;  CFileStatus fstatus; 
    CFile file; 
    LONG cb; 
        
    CDC* pDC = this->GetDC();
    if (file.Open(_T("c:/test.jpg"),CFile::modeRead)&&file.GetStatus(_T("c:/test.jpg"), 
    fstatus)&& ((cb = fstatus.m_size) != -1)) 


    HGLOBAL hGlobal = GlobalAlloc(GMEM_MOVEABLE, cb);  LPVOID pvData = NULL;  if (hGlobal != NULL) 

    if ((pvData = GlobalLock(hGlobal)) != NULL) 

    file.ReadHuge(pvData, cb); 
    GlobalUnlock(hGlobal); 
    CreateStreamOnHGlobal(hGlobal, TRUE, &pStm);  if(SUCCEEDED(::OleLoadPicture(pStm,fstatus.m_size,TRUE,IID_IPicture,(LPVOID*)&pPic))) 

    OLE_XSIZE_HIMETRIC hmWidth; 
    OLE_YSIZE_HIMETRIC hmHeight;  pPic->get_Width(&hmWidth); 
    pPic->get_Height(&hmHeight);  double fX,fY; 
    fX = (double)pDC->GetDeviceCaps(HORZRES)*(double)hmWidth/((double)pDC->GetDeviceCaps(HORZSIZE)*100.0); 
    fY = (double)pDC->GetDeviceCaps(VERTRES)*(double)hmHeight/((double)pDC->GetDeviceCaps(VERTSIZE)*100.0); 
    if(FAILED(pPic->Render(*pDC,0,0,(DWORD)fX,(DWORD)fY,0,hmHeight,hmWidth,-hmHeight,NULL))) 
    AfxMessageBox(_T("Failed To Render The picture!")); 
    pPic->Release(); 

       else 
         AfxMessageBox(_T("Error Loading Picture From Stream!")); 







    else 
    AfxMessageBox(_T("Can't Open Image File!"));
      

  3.   

    不是OnButton1()函数体内的代码问题  
    检查检查头文件和cpp文件OnButton1()是否关联正确
      

  4.   

    是不是忘了引入函数库文件啊 XXX.lib