2012-01-02 10 views
2

g ++を使用してAllegro 5プログラムをコンパイルすると、undefined reference to 'al_init_primitives_addon', al_draw_filled_rectangleおよびallegro_primitives.hにあるそのような関数について不平を言います。それはal_create_displayのようなallegro.hの関数については不平を言っていません。コンパイラがallegro.hを検出しましたが、allegro_primitives.hは検出しません

#include <allegro5/allegro.h> 

#include <allegro5/allegro_primitives.h> 

#include "objects.h" 

#include "main.h" 

コンパイラコマンド:

g++ main.cpp -o game -lallegro -I/usr/include/allegro5 -L/usr/lib/allegro5 

苦情:

が含ま

/tmp/ccAyQlcl.o: In function `main': 
main.cpp:(.text+0xef): undefined reference to `al_init_primitives_addon' 
/tmp/ccAyQlcl.o: In function `Draw()': 
main.cpp:(.text+0x38c): undefined reference to `al_draw_filled_rectangle' 
main.cpp:(.text+0x415): undefined reference to `al_draw_filled_rectangle' 

MSVC++の方法により、この罰金をコンパイルします。

答えて

3

アレグロとアレグロプライムとリンクする必要があります。適切な方法は次のとおりです。

g++ main.cpp -o game $(pkg-config --libs 
    allegro-5.0 allegro_main-5.0 allegro_primitives-5.0) 

(1本のライン上のすべて、もちろん。)

.PCファイルはPKG_CONFIG_PATH環境変数にする必要があります/usr/local/lib/pkgconfigになります。

0

-lallegroにはこれらの機能が含まれていません。システムパスに古いライブラリがあり、必要な5.xのライブラリが/usr/lib/allegro5にある場合、-L-lの前に渡す必要があります。

+0

g ++ main.cpp -o game -I/usr/include/allegro5 -L/usr/lib/allegro5 -lallegro? これは私に同じエラーを与えます。 – awesomeguy

関連する問題