2

Allegro5プログラムをg++を使用してコンパイルするundefined reference to 'al_init_primitives_addon', al_draw_filled_rectangleと、allegro_primitives.hにあるその他の関数について文句を言います。のようなallegro.hの関数については文句を言いませんal_create_display

含まれるもの:

#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++はこれをうまくコンパイルします。

4

2 に答える 2

3

allegro と allegro_primitives をリンクする必要があります。適切な方法は次のとおりです。

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

(もちろん、すべて 1 行で。)

.pc ファイルは、環境変数/usr/local/lib/pkgconfigに必要な場所にあります。PKG_CONFIG_PATH

于 2012-01-02T18:08:46.923 に答える
0

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

于 2012-01-02T06:57:25.323 に答える