C++ ';第一快板';未在此范围中声明

C++ ';第一快板';未在此范围中声明,c++,linux,allegro5,C++,Linux,Allegro5,伙计们,我正试图在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,

伙计们,我正试图在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() 

我的所有主头文件都在
/usr/include/allegro5
中,您是否检查了头文件中是否存在这些方法

您似乎正在使用Allegro 4 API而不是Allegro 5:

谢谢。但我不明白该软件包提供的示例是如何过时和不起作用的。因此,基本代码可以正常工作,但仍然存在一些问题,比如为什么我必须使用
gcc-Wall lesson1.cpp
pkg config--libs allegro-5.0``以及示例中给出的错误,如“未定义引用
al\u show\u native\u message\u box”
可能文档与最新代码不符。未定义的引用是由于
LD\u library\u路径中缺少库
,或者您可能必须更新
LD.so.conf
文件。您在哪里找到lesson1.cpp文件?lesson1.cpp文件中使用的源代码。@Ajinkya,Allegro 5是模块化的。e、 例如,在该示例中,您必须链接allegro、allegro_image和allegro_native_dialog libs。找到了解决方案,程序运行正常。allegro 5与allegro 4不向后兼容。您正在编写Allegro 4代码,使用Allegro 5标题,并与Allegro 4链接。提示:如果函数的前缀是al_3;,那么您将看到Allegro 5教程。你应该在新项目中使用Allegro 5。
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