1

伙计们,我正在尝试在 Ubuntu 11.04 上安装 allegro 5 库。我遵循的教程这样的。现在我在第一次尝试安装库时遇到了一些错误,但我可以克服它们并正确安装库。问题是当我尝试运行我的示例代码时

#include <allegro5/allegro.h> 

int main(int argc, char *argv[]) 

{
allegro_init(); 

install_keyboard(); 

set_gfx_mode(GFX_AUTODETECT, 640,480,0,0); 

readkey();

return 0; 
}

END_OF_MAIN() 

我收到类似的错误

ajinkya@ajinkya-8I945GZME-RH:~/random$ g++ example.cpp -o example -lalleg
example.cpp: In function ‘int main(int, char**)’:
example.cpp:7:15: error: ‘allegro_init’ was not declared in this scope
example.cpp:9:19: error: ‘install_keyboard’ was not declared in this scope
example.cpp:11:15: error: ‘GFX_AUTODETECT’ was not declared in this scope
example.cpp:11:42: error: ‘set_gfx_mode’ was not declared in this scope
example.cpp:13:10: error: ‘readkey’ was not declared in this scope
example.cpp: At global scope:
example.cpp:18:13: error: expected constructor, destructor, or type conversion at end   of input

我有所有的主要头文件/usr/include/allegro5

4

1 回答 1

2

您是否检查过这些方法是否确实存在于头文件中?

您似乎使用的是 Allegro 4 API 而不是 Allegro 5:请参阅http://wiki.allegro.cc/index.php?title=Allegro_5_Tutorial/Displays

于 2012-08-21T12:57:31.340 回答