伙计们,我正在尝试在 Ubuntu 11.04 上安装 allegro 5 库。我遵循的教程 is这。 现在我在第一次尝试安装库时遇到了一些错误,但我可以克服它们并正确安装库。问题是当我尝试运行示例代码时
#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
中有所有主要的头文件。
最佳答案
您是否检查过头文件中是否确实存在这些方法?
您似乎使用的是 Allegro 4 API 而不是 Allegro 5: 见http://wiki.allegro.cc/index.php?title=Allegro_5_Tutorial/Displays
关于c++ - “allegro_init()”未在此范围内声明,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12055200/