2011-02-07 102 views
3

我需要從DLL位置調用EXE內部的幾個函數。而且,我還需要訪問DLL中的EXE內部的一些變量。下面是錯誤列表,可能根本沒有幫助,但附加它。 我通過使用.def文件和dllimport以及其他依賴關係執行了相反的操作(exe- > dll)。而且,現在我被卡住了。 注:Micros * t Visual Studio 2008 pro,Standard-C。調用DLL中的EXE函數

 
3>sv_bot.obj : error LNK2019: 未解決の外部シンボル _SV_GentityNum が関數 _SV_BotAllocateClient で參照されました。 
3>sv_bot.obj : error LNK2001: 外部シンボル "_svs" は未解決です。 
3>sv_bot.obj : error LNK2001: 外部シンボル "_sv_maxclients" は未解決です。 
3>sv_bot.obj : error LNK2001: 外部シンボル "_botlib_export" は未解決です。 
3>sv_bot.obj : error LNK2019: 未解決の外部シンボル _Cvar_Get が関數 _BotDrawDebugPolygons で參照されました。 
3>sv_bot.obj : error LNK2019: 未解決の外部シンボル _SV_Trace が関數 _BotImport_Trace で參照されました。 
3>sv_bot.obj : error LNK2019: 未解決の外部シンボル _SV_ClipToEntity が関數 _BotImport_EntityTrace で參照されました。 
3>sv_bot.obj : error LNK2019: 未解決の外部シンボル _SV_PointContents が関數 _BotImport_PointContents で參照されました。 
3>sv_bot.obj : error LNK2019: 未解決の外部シンボル _SV_inPVS が関數 _BotImport_inPVS で參照されました。 
3>sv_bot.obj : error LNK2019: 未解決の外部シンボル _CM_EntityString が関數 _BotImport_BSPEntityData で參照されました。 
3>sv_bot.obj : error LNK2019: 未解決の外部シンボル _CM_ModelBounds が関數 _BotImport_BSPModelMinsMaxsOrigin で參照されました。 
3>sv_bot.obj : error LNK2019: 未解決の外部シンボル _CM_InlineModel が関數 _BotImport_BSPModelMinsMaxsOrigin で參照されました。 
3>sv_bot.obj : error LNK2019: 未解決の外部シンボル _Z_TagMalloc が関數 _BotImport_GetMemory で參照されました。 
3>sv_bot.obj : error LNK2019: 未解決の外部シンボル _Z_Free が関數 _BotImport_FreeMemory で參照されました。 
3>sv_bot.obj : error LNK2019: 未解決の外部シンボル _Hunk_Alloc が関數 _BotImport_HunkAlloc で參照されました。 
3>sv_bot.obj : error LNK2019: 未解決の外部シンボル _Hunk_CheckMark が関數 _BotImport_HunkAlloc で參照されました。 
3>sv_bot.obj : error LNK2019: 未解決の外部シンボル _SV_ExecuteClientCommand が関數 _BotClientCommand で參照されました。 
3>sv_bot.obj : error LNK2019: 未解決の外部シンボル _VM_Call が関數 _SV_BotFrame で參照されました。 
3>sv_bot.obj : error LNK2001: 外部シンボル "_gvm" は未解決です。 
2> ライブラリ ..\..\build\quake3_release\ioquake3.lib とオブジェクト ..\..\build\quake3_release\ioquake3.exp を作成中 
3>sv_bot.obj : error LNK2019: 未解決の外部シンボル _GetBotLibAPI が関數 _SV_BotInitBotLib で參照されました。 
3>sv_bot.obj : error LNK2019: 未解決の外部シンボル _FS_Seek が関數 _SV_BotInitBotLib で參照されました。 
3>sv_bot.obj : error LNK2019: 未解決の外部シンボル _FS_FCloseFile が関數 _SV_BotInitBotLib で參照されました。 
3>sv_bot.obj : error LNK2019: 未解決の外部シンボル _FS_Write が関數 _SV_BotInitBotLib で參照されました。 
3>sv_bot.obj : error LNK2019: 未解決の外部シンボル _FS_Read2 が関數 _SV_BotInitBotLib で參照されました。 
3>sv_bot.obj : error LNK2019: 未解決の外部シンボル _FS_FOpenFileByMode が関數 _SV_BotInitBotLib で參照されました。 
3>sv_bot.obj : error LNK2019: 未解決の外部シンボル _Z_AvailableMemory が関數 _SV_BotInitBotLib で參照されました。 
3>sv_bot.obj : error LNK2019: 未解決の外部シンボル _Z_Malloc が関數 _SV_BotInitBotLib で參照されました。 
3>sv_bot.obj : error LNK2019: 未解決の外部シンボル _Cvar_VariableIntegerValue が関數 _SV_BotInitBotLib で參照されました。 
3>..\..\build\game_release\qagamex86.dll : fatal error LNK1120: 外部參照 28 が未解決です。 
2>LINK : warning LNK4098: defaultlib 'LIBCMT' は他のライブラリの使用と競合しています。/NODEFAULTLIB:library を使用してください。 
3>ビルドログは "file://c:\Documents and Settings\yasir\デスクトップ\ioquake3dev\ioquake3dev - sandbox\build\game_release\BuildLog.htm" に保存されました。 
3>game - エラー 29、警告 0 
2>LINK : warning LNK4199: /DELAYLOAD:OleAcc.dll は無視されます。OleAcc.dll にインポートがありません。 
2>cm_patch.obj : error LNK2019: 未解決の外部シンボル _BotDrawDebugPolygons が関數 _CM_DrawDebugSurface で參照されました。 
2>sv_client.obj : error LNK2019: 未解決の外部シンボル _SV_BotFreeClient が関數 _SV_DropClient で參照されました。 
2>sv_game.obj : error LNK2001: 外部シンボル "_SV_BotFreeClient" は未解決です。 
2>sv_game.obj : error LNK2019: 未解決の外部シンボル _SV_BotGetConsoleMessage が関數 _SV_GameSystemCalls で參照されました。 
2>sv_game.obj : error LNK2019: 未解決の外部シンボル _SV_BotGetSnapshotEntity が関數 _SV_GameSystemCalls で參照されました。 
2>sv_game.obj : error LNK2019: 未解決の外部シンボル _SV_BotLibShutdown が関數 _SV_GameSystemCalls で參照されました。 
2>sv_game.obj : error LNK2019: 未解決の外部シンボル _SV_BotLibSetup が関數 _SV_GameSystemCalls で參照されました。 
2>sv_game.obj : error LNK2019: 未解決の外部シンボル _BotImport_DebugPolygonDelete が関數 _SV_GameSystemCalls で參照されました。 
2>sv_game.obj : error LNK2019: 未解決の外部シンボル _BotImport_DebugPolygonCreate が関數 _SV_GameSystemCalls で參照されました。 
2>sv_game.obj : error LNK2019: 未解決の外部シンボル _SV_BotAllocateClient が関數 _SV_GameSystemCalls で參照されました。 
2>sv_game.obj : error LNK2001: 外部シンボル "_bot_enable" は未解決です。 
2>sv_init.obj : error LNK2019: 未解決の外部シンボル _SV_BotFrame が関數 _SV_SpawnServer で參照されました。 
2>sv_main.obj : error LNK2001: 外部シンボル "_SV_BotFrame" は未解決です。 
2>sv_init.obj : error LNK2019: 未解決の外部シンボル _SV_BotInitBotLib が関數 _SV_Init で參照されました。 
2>sv_init.obj : error LNK2019: 未解決の外部シンボル _SV_BotInitCvars が関數 _SV_Init で參照されました。 
2>..\..\build\quake3_release\ioquake3.exe : fatal error LNK1120: 外部參照 13 が未解決です。 
2>ビルドログは "file://c:\Documents and Settings\yasir\デスクトップ\ioquake3dev\ioquake3dev - sandbox\build\quake3_release\BuildLog.htm" に保存されました。 
2>quake3 - エラー 16、警告 2 
========== ビルド: 0 正常終了、2 失敗、2 更新不要、1 スキップ ========== 
+2

而不是直接從DLL調用它們,爲什麼不傳遞一個函數指針指向main .exe函數?這樣你也可以減少程序中的「緊密耦合」。 – Lundin 2011-02-07 09:44:50

回答

1

我想你不能將DLL鏈接到你的EXE。相反,請定義一個包含函數指針的結構,並在您的exe中初始化此結構的一個實例。將指向你的函數的指針指向結構實例中的指針。調用DLL函數將指向結構實例的指針存儲在DLL的靜態變量中。只要你的DLL想調用一個EXE函數,就使用struct實例中的一個函數指針調用這個函數。

+0

謝謝你的建議。我需要時間來實施和測試這個,並回來反饋。 – user598208 2011-02-07 11:25:30