2017-03-17 125 views
0

我試圖移植使用Allegro 5.0(從Windows到運行Raspian的Raspberry Pi)的遊戲。我安裝了Allegro並移動了所有源文件,但是當我嘗試使用以下代碼編譯時:* g ++ -std = C++ 0x .cpp -o SpaceFighter $(pkg-config --libs allegro-5) I得到如下:Allegro 5遊戲不會與GCC編譯

/tmp/ccBliSky.o:在功能main': main.cpp:(.text+0x130): undefined reference to al_show_native_message_box ' 的main.cpp :(文字+ 0x160):未定義的引用al_init_font_addon' main.cpp:(.text+0x164): undefined reference to al_init_ttf_addon' 的main.cpp :(文字+ 0x168):未定義的參考al_init_image_addon' main.cpp:(.text+0x1a4): undefined reference to al_load_ttf_font' main.cpp :(。text + 0x574):未定義的參考al_draw_textf' /tmp/ccBMyqom.o: In function MenuItem :: MenuItem()': MenuItem.cpp :(。text + 0xa0):未定義的參考al_load_ttf_font' /tmp/ccBMyqom.o: In function Men MenuItem.cpp :(。text + 0x1ac):未定義引用al_destroy_font' /tmp/ccBMyqom.o: In function MenuItem :: Draw(GameTime const *)': MenuItem.cpp :(。text + 0x2fc):undefined reference到al_draw_text' /tmp/ccKXP3ds.o: In function PlayerShip :: SetAudioSample(的std :: string) ': PlayerShip.cpp :(文字+ 0x604):未定義的引用al_destroy_sample' PlayerShip.cpp:(.text+0x64c): undefined reference to al_load_sample' collect2:錯誤:LD返回1退出狀態

與不,這不是重複的「什麼是未定義的參考/未解決的外部符號錯誤?什麼是常見的原因,以及如何修復/阻止他們?」

我知道通常會導致最未定義引用錯誤,這個問題是特定於我用快板圖書館。

下面是一段代碼(我顯然不會張貼了整場比賽):

#include <allegro5/allegro.h> 
#include <allegro5/allegro_native_dialog.h> 

#include <allegro5/allegro_font.h> 
#include <allegro5/allegro_ttf.h> 
#include <allegro5/allegro_image.h> 

#include <iostream> 

#include "Game.h" 


int main(int argc, char *argv[]) 
{  
    const char errorType[] = "Initialization Error"; 
    const int flags = ALLEGRO_MESSAGEBOX_ERROR; 

    // Initialize Allegro 
    if (!al_init()) 
    { 
     const char message[] = "Failed to initialize Allegro Library."; 
     //al_show_native_message_box(nullptr, "Error", errorType, message, nullptr, flags); 
     return -1; 
    } 

    Game game; 

    // Initialize a new window for gameplay. 

    int screenWidth = Game::GetScreenWidth(); 
    int screenHeight = Game::GetScreenHeight(); 

預先感謝任何幫助

+0

的可能的複製[?什麼是未定義參考/解析的外部符號錯誤,以及如何解決呢(http://stackoverflow.com/questions/12573816/what-is-an-undefined -reference懸而未決,外部符號錯誤和如何-DO-修復) –

回答

2

ALEGRO在幾個模塊把它的功能你pkg-config行必須包括您所使用的所有模塊!試試看因爲:

pkg-config --libs allegro-5 allegro_font-5 allegro_image-5 allegro_ttf-5