编译器检测到 allegro.h,但未检测到 allegro_primitives.h
当我使用 g++ 编译 Allegro 5 程序时,它抱怨 对 '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++ 编译这个很好。
When I compile my Allegro 5 program using g++, it complains about undefined reference to 'al_init_primitives_addon', al_draw_filled_rectangle
and other such functions that are found in allegro_primitives.h. It does not complain about functions in allegro.h like al_create_display
.
Includes:
#include <allegro5/allegro.h>
#include <allegro5/allegro_primitives.h>
#include "objects.h"
#include "main.h"
Compiler command:
g++ main.cpp -o game -lallegro -I/usr/include/allegro5 -L/usr/lib/allegro5
Complaints:
/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++ compiles this fine, by the way.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您需要链接 allegro 和 allegro_primitives。正确的方法是:(
当然,全部在一行。)
.pc 文件将位于
/usr/local/lib/pkgconfig
中,它需要位于您的PKG_CONFIG_PATH
中> 环境变量。You need to link with allegro and allegro_primitives. The proper way is:
(All on one line, of course.)
The .pc files will be in
/usr/local/lib/pkgconfig
which needs to be in yourPKG_CONFIG_PATH
environment variable.您的
-lallegro
不包含这些函数。如果系统路径中有一个旧的库,并且在/usr/lib/allegro5
中有所需的 5.x 库,则需要在- 之前传递
-L
升。Your
-lallegro
doesn't contain these functions. If you have an old library in system paths and the needed 5.x one in/usr/lib/allegro5
, you need to pass your-L
before-l
.