mr923 发表于 2018-5-6 09:54:32

ubuntu下code::blocks环境中allegro5的安装配置

  我的系统是lubuntu11.04。
  1. 安装code::blocks
  2. 安装allegro5的依赖包,包括


[*]libgl1-mesa-dev
[*] libglu1-mesa-dev
[*] cmake
[*] build-essential
[*] make

  3.下载allegro5源代码
  官网 http://alleg.sourceforge.net/
  4.解压、编译、安装


[*]$ cd allegro5
[*]$ mkdir build
[*]$ cd build
[*]$ cmake ..
[*]# or run cmakegui ..
[*]$ make
[*]$ sudo make install

  此时用gcc编译文件test.c的命令为


[*]gcc testal.c -o test -lallegro

  或者


[*]gcc test.c -o test $(pkg-config --libs allegro-5.0 allegro_image-5.0)

  更多相关信息可以查看下载的源码包中README_pkgconfig.txt文件
  5.配置code::blocks
  用


[*]pkg-config --list-all | grep allegro

  查看allegro5库文件
  用


[*]pkg-config --cflags --libs allegro-5.0

  查看头文件
  在code::blocks中
  setting->compiler and debugger settings ->linker settings
  点击add,选/usr/local/lib下所有的liballegro开头的文件,
  setting->compiler and debugger settings ->search directories
  点add,选/usr/local/include
  确定后在code::blocks中建console项目,添加源代码


[*]#include <stdio.h>
[*]#include <allegro5/allegro.h>
[*]
[*]int main(int argc, char **argv)
[*]{
[*]    ALLEGRO_DISPLAY *display = NULL;
[*]
[*]   if(!al_init()) {
[*]      fprintf(stderr, &quot;failed to initialize allegro!\n&quot;);
[*]      return -1;
[*]   }
[*]
[*]   display = al_create_display(640, 480);
[*]   if(!display) {
[*]      fprintf(stderr, &quot;failed to create display!\n&quot;);
[*]      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;
[*]}

编译、运行即可。

游戏编写完成后如果需要隐藏console窗口,按照

http://wiki.allegro.cc/index.php?title=Hiding_the_console_window_with_Code::Blocks

设置即可
页: [1]
查看完整版本: ubuntu下code::blocks环境中allegro5的安装配置