编译器检测 allegro.h,但不检测 allegro_primitives.h
Compiler detects allegro.h, but not allegro_primitives.h
当我使用 g++ 编译我的 Allegro 5 程序时,它抱怨 undefined reference to 'al_init_primitives_addon', al_draw_filled_rectangle
和 allegro_primitives.h 中的其他此类函数。它不会像 al_create_display
那样抱怨 allegro.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++ 编译得很好。
您需要
与 allegro 和 allegro_primitives 链接。正确的方法是:
g++ main.cpp -o game $(pkg-config --libs
allegro-5.0 allegro_main-5.0 allegro_primitives-5.0)
(当然,所有这些都在一行上。
.pc 文件将位于需要位于PKG_CONFIG_PATH
环境变量中的/usr/local/lib/pkgconfig
。
您的-lallegro
不包含这些函数。如果您在系统路径中有一个旧库,并且在/usr/lib/allegro5
中有一个所需的 5.x 库,则需要在-l
之前传递您的-L
。
相关文章:
- 使用CMake检测支持的C++标准
- 当套接字连接断开时检测C/C++Unix
- C/C++预处理器是否可以检测一些编译器选项
- WMI检测进程创建事件-c++
- 基于树莓pi的tensorflow lite量化ssd目标检测
- 下面是我为检测链接列表中的循环而制作的代码
- 落砂模拟碰撞检测C++和SFML
- 我可以检测和更改 gcc/g++ 中结构的当前数据对齐设置吗?
- 为什么C++编译器没有检测到正确声明的类?
- 检测win32服务创建和删除的最佳方法
- 正在LLVM中检测整数比较条件
- 如何在鼠标挂钩过程中检测拖动
- 位移操作和位掩码未检测到重复字符
- 检测 COFF 对象文件中C++内联符号
- qmake:检测目标位宽(32 位或 64 位)
- 增强精神解析器规则以检测语句中的特殊结尾
- 用于C++的静态二进制检测或二进制重写工具和框架
- Tensorflow对象检测在Python和C++(OpenCV)之间有不同的结果
- Allegro Circle碰撞检测
- 编译器检测 allegro.h,但不检测 allegro_primitives.h