我对 Code::Blocks 中的 Allegro 5.0.10 库有疑问。它们似乎没有正确链接,因为当我尝试从 wiki 编译示例时:
#include <stdio.h>
#include <allegro5/allegro.h>
int main(int argc, char **argv)
{
ALLEGRO_DISPLAY *display = NULL;
if(!al_init())
{
fprintf(stderr, "failed to initialize allegro!\n");
return -1;
}
display = al_create_display(640, 480);
if(!display)
{
fprintf(stderr, "failed to create display!\n");
return -1;
}
al_clear_to_color(al_map_rgb(0,0,0));
al_flip_display();
al_rest(10.0);
al_destroy_display(display);
return 0;
}
编译器给出了一系列错误,例如:D:/C++Dev/workspace/Obvi/Main.cpp:10: undefined reference to 'al_install_system'
. 我试图通过使用“其他链接器选项”链接来修复它。(-lallegro-5.0.10-monolith-static-mt),但随后链接器给出错误:D:/TDM-GCC-64/bin/../lib/gcc/x86_64-w64-mingw32/4.9.2/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find -lallegro-5.0.10-monolith-static-mt
. 我添加了“搜索目录”:链接器的库,以及编译器的包含。在构建日志中我还发现:D:/TDM-GCC-64/bin/../lib/gcc/x86_64-w64-mingw32/4.9.2/../../../../x86_64-w64-mingw32/bin/ld.exe: skipping incompatible D:\C++Dev\libs\allegro-5.0.10-mingw-4.7.1-tdm\lib/liballegro-5.0.10-monolith-static-mt.a when searching for -lallegro-5.0.10-monolith-static-mt
它告诉链接器找到库,但由于某种原因忽略了它。