编译器检测到allegro.h,但不是allegro_primitives.h [英] Compiler detects allegro.h, but not allegro_primitives.h

查看:289
本文介绍了编译器检测到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>

#includeobjects.h

#includemain.h

编译器命令:

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

投诉:

  /tmp/ccAyQlcl.o:函数`main':
main.cpp :( .text + 0xef):未定义的引用'al_init_primitives_addon'
/tmp/ccAyQlcl.o:在函数`Draw()'中:
main.cpp :(。text + 0x38c):未定义引用'al_draw_filled_rectangle'
main.cpp :(。 text + 0x415):对`al_draw_filled_rectangle'的未定义引用

顺便说一句,MSVC ++编译这个很好。 / p>

解决方案

您需要链接allegro和allegro_primitives。正确的方法是:

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

(当然,所有内容都在同一行上)



.pc文件位于 / usr / local / lib / pkgconfig 中c> PKG_CONFIG_PATH 环境变量。


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.

解决方案

You need to link with allegro and allegro_primitives. The proper way is:

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

(All on one line, of course.)

The .pc files will be in /usr/local/lib/pkgconfig which needs to be in your PKG_CONFIG_PATH environment variable.

这篇关于编译器检测到allegro.h,但不是allegro_primitives.h的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆