我一直在尝试使用Allegro版本5.2,但由于某些原因,我无法使用MinGW在我的系统(运行Windows1064位)上编译它。
My Linker Settings
这就是我想要链接的。根据wiki的说法,这应该是正确的,但是每当我尝试编译示例代码时,我都会得到这样的错误
src\game.c|13|undefined reference to `al_clear_to_color'|据我所知,这个函数应该是存在的。
我真的很感谢大家的帮助:)
下面是一个无法编译的代码示例
#include"../include/init.h"
#include "allegro5/allegro5.h"
#include"allegro5/allegro_audio.h"
#include"allegro5/allegro_acodec.h"
#include<stdio.h>
#include<stdlib.h>
const float fps = 30;
const int width = 256;
const int height = 240;
int init() {
running = 1;
if(!al_init()) {
fprintf(stderr, "failed to initialize allegro!\n");
return -1;
}
timer = al_create_timer(1.0 / fps);
if(!timer) {
fprintf(stderr, "failed to create timer!\n");
return -1;
}
display = al_create_display(width, height);
if(!display) {
fprintf(stderr, "failed to create display!\n");
return -1;
}
event_queue = al_create_event_queue();
if(!event_queue) {
fprintf(stderr, "failed to create event_queue!\n");
return -1;
}
/*if(!al_install_audio()){
fprintf(stderr, "failed to initialize audio!\n");
return -1;
}
if(!al_install_keyboard()) {
fprintf(stderr, "failed to initialize the keyboard!\n");
return -1;
}
if(!al_init_acodec_addon()){
fprintf(stderr, "failed to initialize audio codecs!\n");
return -1;
}
if (!al_reserve_samples(1)){
fprintf(stderr, "failed to reserve samples!\n");
return -1;
}*/
if(!al_init_primitives_addon()) {
fprintf(stderr, "failed to create primitives addon");
return -1;
}
al_register_event_source(event_queue, al_get_display_event_source(display));
// register timer event for max fps
al_register_event_source(event_queue, al_get_timer_event_source(timer));
//al_register_event_source(event_queue, al_get_keyboard_event_source());
al_clear_to_color(al_map_rgb(0,0,0));
al_flip_display();
al_start_timer(timer);
return 1;
}发布于 2016-06-29 04:13:15
使用al_map_rgb_f()函数来映射颜色,像这样:al_clear_to_color(al_map_rgb(255, 255, 255));?
你能在这里插入你的代码吗?
对不起,这不应该是一个答案,因为我没有名气来评论它。
发布于 2016-11-01 22:19:57
我可以在您的链接器设置中看到,您可以分别链接整体版本和所有模块。整体式版本是将所有其他模块合并为一个模块,使您不需要所有其他allegro_*库。也许这里面有冲突?除此之外,检查日志并检查问题是否与Debug和Release有关。
发布于 2019-03-23 00:30:31
你的链接器设置都乱七八糟。您混合了动态库和静态库,以及整体库和非整体库。
以.dll.a结尾的库是导入归档。仅以.a结尾的库是静态库归档。当您链接到动态allegro单体时,您不需要链接到其他任何东西。
当你链接到静态的allegro库时,你也必须链接它们的依赖关系。
顺便说一句,我一般不推荐使用代码块项目链接器设置中的“链接库”窗格。改为设置链接器包含目录和链接器选项。它允许您随意更改链接目录,而无需更改任何库链接选项。这样,你就可以随意升级你的allegro和其他库了。否则,您必须删除并重新添加所有链接库。
https://stackoverflow.com/questions/38084700
复制相似问题