您沒有鏈接的.lib文件。
也許這可以幫助你
http://www.coderetard.com/2009/01/21/generate-a-lib-from-a-dll-with-visual-studio/
或本:
http://support.microsoft.com/default.aspx?scid=kb;en-us;131313
或本:
http://www.asawicki.info/news_1420_generating_lib_file_for_dll_library.html
,當你有屬在lib文件中,你必須在頭文件的yuor函數上使用__declspec(dllimport)
。
上述所有方法的替代方法是在源代碼中使用LoadLibrary(...),並在dll中爲這些函數編寫包裝函數,並通過GetProcAddress(...)調用這些dll函數。
struct
{
HMODULE hDll;
int (*BIM482OpenRadar) ();
int (*BIM482AddPlane) (double x, double y);
int (*BIM482SetPlaneColor) (int planeidx, int coloridx);
int (*BIM482SetPlanePos) (int planeidx, double x, double y);
void (*BIM482UpdateRadar) ();
} dll_funcs = {0};
bool ExitRadar(LPCTSTR szDllPath)
{
if (dll_funcs.hDll)
FreeLibrary(dll_funcs.hDll);
return true;
}
bool InitRadar(LPCTSTR szDllPath)
{
if (dll_funcs.hDll)
return true;
dll_funcs.hDll = LoadLibrary(szDllPath);
if (!dll_funcs.hDll)
return false;
dll_funcs.BIM482OpenRadar = (int(*)())GetProcAddress(dll_funcs.hDll ,("BIM482OpenRadar"));
dll_funcs.BIM482AddPlane = (int(*)(double,double))GetProcAddress(dll_funcs.hDll ,("BIM482AddPlane"));
dll_funcs.BIM482SetPlaneColor = (int(*)(int,int))GetProcAddress(dll_funcs.hDll ,("BIM482SetPlaneColor"));
dll_funcs.BIM482SetPlanePos = (int(*)(int,double,double))GetProcAddress(dll_funcs.hDll ,("BIM482SetPlanePos"));
dll_funcs.BIM482UpdateRadar = (void(*)())GetProcAddress(dll_funcs.hDll ,("BIM482UpdateRadar"));
return true;
}
int BIM482OpenRadar ()
{ return (*dll_funcs.BIM482OpenRadar)(); };
int BIM482AddPlane (double x, double y)
{ return (*dll_funcs.BIM482AddPlane)(x ,y); }
int BIM482SetPlaneColor (int planeidx, int coloridx)
{ return (*dll_funcs.BIM482SetPlaneColor)(planeidx ,coloridx); }
int BIM482SetPlanePos (int planeidx, double x, double y)
{ return (*dll_funcs.BIM482SetPlanePos)(planeidx ,x ,y); }
void BIM482UpdateRadar ()
{ return (*dll_funcs.BIM482UpdateRadar)(); }
增加了VS2010標籤的相關性。 – Maxpm 2011-01-19 03:14:01