2012-03-23 48 views
0

我們正在嘗試爲我們的遊戲引擎構建編輯器,因此我們在編輯器Proj中的引擎和鏈接中創建了一個庫。 在Proj中註釋了Lib和Include Dir的路徑。支柱。 我嘗試過,沒有WinAPI,但鏈接錯誤仍然存​​在。 直接在Header工作中定義的函數,但在C++文件中定義的函數正在創建鏈接錯誤。我必須在Proj中添加.cpp文件,是不是完全是這樣的庫? -.-自制Lib的鏈接錯誤

操作系統:Windows 7 64位

Visual Studio 2010中

#include "pch.h" 

Application* g_pApp = NULL; 

INT WINAPI WinMain(__in HINSTANCE hInstance, __in_opt HINSTANCE hPrevInstance, __in LPSTR lpCmdLine, __in int nShowCmd) 
{ 
BlocoApp blocoApp(&g_pApp); 

// start engine 
Editor mainForm; 
if(!g_pApp->Init(L"Bloco", 1600, 900, true, hInstance)) 
{ 
    g_pApp->Exit(); 
    return 1; 
} 

// main loop 
DXUTMainLoop(); 

g_pApp->Exit(); 

return 0; 
} 

的編譯器錯誤:

error LNK2001: Nicht aufgelöstes externes Symbol ""public: bool __thiscall Application::Init(class std::basic_string<unsigned short,struct std::char_traits<unsigned short>,class std::allocator<unsigned short> >,unsigned int,unsigned int,bool,struct HINSTANCE__ *,struct HWND__ *)" ([email protected]@@[email protected][email protected]@[email protected]@[email protected]@[email protected]@[email protected]@[email protected]@[email protected]@@Z)". 
+0

也許你可以分享一些代碼?此外鏈接器給你的具體錯誤信息。 – Attila 2012-03-23 21:10:24

+0

請發佈實際錯誤(複製粘貼)。有問題的功能(和呼叫站點)的來源可能會有所幫助。我很驚訝這種事情需要多少次被要求。 – 2012-03-23 21:13:19

+0

抱歉,忘了源代碼^^ – 2012-03-23 21:19:59

回答

0

The Path for the Lib ... are remarked in the Proj. prop

我懷疑你已經配置的目錄該庫位於項目的「附加庫目錄」設置中。這將配置鏈接器將查找它被要求查找的庫文件的位置。

但是,您還需要告訴鏈接器將庫實際包含爲輸入文件。這是在IDE中使用「Input/Additional Dependencies」屬性完成的。

+0

在pch.h標題中添加了附註註釋(lib,「bloco.lib」),其中還包含#include 。我的句子肯定是不正確的gg – 2012-03-23 21:39:32

+0

@MathiasHölzl:噢 - 'pragma'應該可以做到。如果你這樣做,輸出結果是:'dumpbin/symbols bloco.lib |找到「Init」? (最好將結果粘貼到問題中 - 我認爲評論不會格式化得很好)。 – 2012-03-23 22:01:26

+0

我需要把這個命令放在哪裏?我用鏈接器命令行嘗試了它,但是它發現這個命令是未定義的。 – 2012-03-23 22:13:30