2012-10-15 42 views
0

我想使用WindowsCodecs.dll中的函數,但MinGW具有不完整且缺少WinAPI標頭以及導入庫。請看下面的演示:無法鏈接到WICConvertBitmapSource

#define WIN32_LEAN_AND_MEAN 
#include <windows.h> 
#include <stdio.h> 

// ---------- dummy declarations, because MinGW got no wincodec.h ---------- 
typedef REFGUID REFWICPixelFormatGUID; 
typedef VOID IWICBitmapSource; 

HRESULT WINAPI WICConvertBitmapSource(
    REFWICPixelFormatGUID dstFormat, 
    IWICBitmapSource *pISrc, 
    IWICBitmapSource **ppIDst); 
// ------------------------------------------------------------------------- 

int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrev, LPSTR lpLine, int nShow) 
{ 
#ifdef LOAD_FROM_DLL 
    typedef HRESULT (WINAPI *PWICConvertBitmapSource)(
     REFWICPixelFormatGUID, IWICBitmapSource *, IWICBitmapSource **); 

    HMODULE hDll = LoadLibrary("WindowsCodecs.dll"); 
    PWICConvertBitmapSource pFunc = 
     (PWICConvertBitmapSource)GetProcAddress(hDll, "WICConvertBitmapSource"); 
    printf("WICConvertBitmapSource: 0x%p.\n", pFunc); 
    pFunc(NULL, NULL, NULL); 
    FreeLibrary(hDll); 
#else 
    WICConvertBitmapSource(NULL, NULL, NULL); 
#endif 
    return 0; 
} 

gcc test.c -DLOAD_FROM_DEF建成,功能的程序打印地址和正確終止。雖然,當與導入庫從以下DEF鏈接:

LIBRARY WindowsCodecs.dll 
EXPORTS 
    [email protected] 

,這個錯誤彈出:

The procedure entry point [email protected] could 
not be located in the dynamic link library WindowsCodecs.dll. 

令人驚訝的是,如果我從高清去除WICConvertBitmapSource從源頭和@12聲明文件,程序鏈接並運行正常。

如何創建正確的導入庫?

備註:我在Windows 7 SP1上運行MinGW。我的gcc版本是4.7.0,安裝了w32api 3.17。該問題出現在許多功能中,如GdiAlphaBlendSHCreateStreamOnFileEx

回答

0

導入庫應該已經和--kill-at標誌創建的,是這樣的:

dlltool --kill-at -D WindowsCodecs.dll -d WindowsCodecs.def -l libwindowscodecs.a 

本文澄清了我的一切:http://wyw.dcweb.cn/stdcall.htm