2013-03-16 38 views
0

使用Visual Studio 10,我未能通過openal錯誤LNK2019同時使用ALUT

http://connect.creativelabs.com/openal/Downloads/Forms/AllItems.aspx

我已經安裝了OpenAL11CoreSDK編譯提供的示例代碼,執行oalinst.exe,還下載freealut-1.1.0-bin
我已經我將alut.lib和OpenAL32.lib放在「Microsoft Visual Studio 10.0 \ VC \ include \庫「 我把alut.dll和OpenAL32.dll放在「C:\ Windows \ SysWOW64」和「C:\ Windows \ System32」中
我已將「Microsoft Visual Studio 10.0 \ VC \ include \ AL」項目 - >屬性 - > VC++目錄 - >包含目錄「和」C/C++ - >常規 - >其他包含目錄「
」庫目錄「和」鏈接器 - >常規 - >其他庫目錄中的「VC \ lib」 「 的路徑‘alut.lib’和‘OpenAL.lib’中的‘連接器 - >輸入 - >附加依賴’

我想我已經聯繫所有的圖書館,但我仍然得到鏈接錯誤:

1>test.obj : error LNK2019: unresolved external symbol __imp__alSourcePlay referenced in function _main 
1>test.obj : error LNK2019: unresolved external symbol __imp__alSourcei referenced in function _main 
1>test.obj : error LNK2019: unresolved external symbol __imp__alGenSources referenced in function _main<br> 
1>C:\Users\SONY\Documents\Visual Studio 2010\Projects\test\Debug\test.exe : fatal error LNK1120: 3 unresolved externals 


#include <stdlib.h> 
#include <AL/alut.h> 

/* 
    This is the 'Hello World' program from the ALUT 
    reference manual. 

    Link using '-lalut -lopenal -lpthread'. 
*/ 

int 
main (int argc, char **argv) 
{ 
    ALuint helloBuffer, helloSource; 
    alutInit (&argc, argv); 
    helloBuffer = alutCreateBufferHelloWorld(); 
    alGenSources (1, &helloSource); 
    alSourcei (helloSource, AL_BUFFER, helloBuffer); 
    alSourcePlay (helloSource); 
    alutSleep (1); 
    alutExit(); 
    return EXIT_SUCCESS; 
} 

我迷路了,我究竟做錯了什麼?

+0

你說你的鏈接器輸入使用OpenAL.lib運行編譯可執行文件,但lib文件是alut.lib – thisisdog 2013-03-16 19:40:21

+0

即使「OpenAL.lib」的路徑已從鏈接器輸入中刪除,它也不起作用。 – millie 2013-03-17 04:32:39

回答

0

讓OpenAL和ALUT工作只需要三個人約5個小時。我相信我的問題與你的問題不同,但我也確信,在你解決問題後,你會碰到另一個問題。與其他海報不同,我不會用一個答案來解決你的問題 - 我不認爲有一個適用於每個人的單一問題。第一步:安裝oalinst.exe。這是OpenAL的安裝程序。沒有使用安裝程序,我們無法讓OpenAL工作。這部分特別棘手,因爲有多個版本以相同的文件名運行。你想要的是最新版本。在撰寫本文時,我正在使用的是June 02, 2009。您可以通過右鍵單擊文件並轉至Properties->Digital Signature來查找這些日期。

在我們的例子中,oalinst在System32和SysWow64中安裝OpenAL32.dll; OpenAL CoreSDK內部還有一個OpenAL32.dll - 所有這些都是不同的

第2步:確保您的程序儘可能地被弄糊塗。來自OpenAL的你好世界很好。

第3步:確保你有FreeALUT。

第4步:在Visual Studio中檢查您的依賴關係。右鍵單擊Visual Studio中的項目(即解決方案資源管理器樹中的解決方案正下方的項目),然後轉至

Properties > Configuration Properties > C/C++ > General > Additional Include Directories (more)

STUFF\OpenAL\OpenAL 1.1\include 
STUFF\OpenAL\freealut-1.1.0-bin\include 
STUFF\OpenAL\OpenAL 1.1\include\AL 

確保STUFF與您擁有的目錄結構匹配。稍後保存一些挫敗感,並檢查您鍵入的路徑是否可以複製粘貼到Windows資源管理器中,並將您置於正確的位置。

現在, Properties > Configuration Properties > Linker > General > Additional Library Directories (more)

STUFF\OpenAL\OpenAL 1.1\libs\Win32 
STUFF\OpenAL\freealut-1.1.0-bin\lib 

與上次相同。

最後, Properties > Configuration Properties > Linker > Input > Additional Dependencies

OpenAL32.lib 
alut.lib 

  1. 確保關閉Visual Studio。做清潔。重拍。跑。如果您從Debug切換到Release,請記住您需要重做屬性頁面。

其餘的由你決定。當您構建發行版或調試版本時,alut.dllalut.lib應顯示在相應的調試或發佈文件夾中。

不要害怕,只是儘量不Visual Studio的(即,只是在hello_world.exe雙擊)