2017-03-17 133 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