2017-06-22 88 views
-1

我對Open AL完全陌生。 於是我開始通過命令行打開AL的函數在使用Ubuntu中的g ++進行編譯時給出未定義引用的錯誤

sudo apt-get install libopenal-dev 

安裝Open AL庫,我也安裝了這個命令

sudo apt-get install libalut0 libalut-dev 

而且我分叉開放鋁從http://kcat.strangesoft.net/openal.html 安裝ALUT並安裝它也。 但是,當我試圖編譯這個簡單程序:

#include <stdio.h> 
#include <AL/al.h> 
#include <AL/alc.h> 
#include <AL/alut.h> 
int main(){ 
    ALCdevice *device; 
    device=alcOpenDevice(NULL); 
    if(!device) 
    { 
     printf("no device found"); 
    } 
    else 
    { 
     printf("device found"); 
    } 
    return 0; 
} 

我收到此錯誤:

/tmp/cchMpaeS.o:在功能main': altest.cpp:(.text+0xe): undefined reference to alcOpenDevice」

collect2:錯誤:LD返回1退出狀態

g++ altest.cpp 
g++ -std=c++11 altest.cpp 
編譯它

他們都給出了同樣的錯誤。

+0

如果你嘗試過的東西,你有問題吧,請發表你嘗試過什麼。在這種情況下,你試圖編譯你的程序,但是你還沒有發佈你嘗試使用的命令。所以發佈該命令。 – nos

+0

@nos我編輯了問題 – Souravirus

回答

0

您需要鏈接到的OpenAL庫:

g++ -std=c++11 altest.cpp -lopenal 
+0

感謝它的工作 – Souravirus

相關問題