c++ - “allegro_init()”未在此范围内声明

标签 c++ linux allegro5

伙计们,我正在尝试在 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/

相关文章:

c++ - 使用 al_ustr_newf 复制字符串 Allegro 5

linux - 在 linux 上调用 "clone()"但似乎出现故障

c++ - 快板 5 中的抗锯齿

c++ - 仅在添加第二个项目后才出现第一个项目的编译错误

c++ - 如何将函数指针作为参数传递给重载的成员函数

MySQL:学校服务器上的错误 1227 (42000)

mysql - 奇怪的 ubuntu bash 问题

c++ - fatal error : allegro5\allegro. h:在 cmake 上尚未找到此类文件或目录

c++ - 二维数组,*(pointerArray[i] + j)是什么意思?

c++ - 我需要独立于平台的 CharToOem 版本。 Boost有吗?