Compiling C++ code with allegro 5 and g++(使用 allegro 5 和 g++ 编译 C++ 代码)
问题描述
为了使用 allegro 5 编译代码,我需要向 g++ 添加哪些标志?我试过了
What flags do I need to add to g++ in order to compile code using allegro 5? I tried
g++ allegro5test.cpp -o allegro5test `allegro-config --libs`
但这不起作用.我正在使用 ubuntu 11.04.我使用 http://wiki.allegro.cc 中的说明安装了 allegro 5/index.php?title=Install_Allegro5_From_SVN/Linux/Debian
but that is not working. I'm using ubuntu 11.04. I installed allegro 5 using the instructions at http://wiki.allegro.cc/index.php?title=Install_Allegro5_From_SVN/Linux/Debian
我试过了:
g++ allegro5test.cpp -o allegro5test `allegro-config --cflags --libs`
而且它还给出了一堆未定义的错误,例如:未定义的对 `al_install_system' 的引用
And it also gives a bunch of undefined errors, like: undefined reference to `al_install_system'
allegro-config --cflags --libs
输出:
-I/usr/local/include
-L/usr/local/lib -lalleg
推荐答案
这样您就成功地从 SVN 将 allegro5 安装到了您的系统上.您应该知道的一件事是,此版本不附带 allegro-config.如果您的系统上有它,则表示您以前安装了 allegro4.
So you successfully installed allegro5 on your system from the SVN. One thing you should know is that this build doesn't come with allegro-config. If you have it on your system it means you have previously installed allegro4.
allegro5 带来了很多变化,包括不同的初始化程序、库和函数名称.
allegro5 brings many changes, including different initialization procedures, library and function names.
这是一个新版本的 hello world 应用程序:
Here's a hello world application for new version:
#include <stdio.h>
#include <allegro5/allegro.h>
int main(int argc, char **argv)
{
ALLEGRO_DISPLAY *display = NULL;
if(!al_init()) {
fprintf(stderr, "failed to initialize allegro!
");
return -1;
}
display = al_create_display(640, 480);
if(!display) {
fprintf(stderr, "failed to create display!
");
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;
}
注意编译此应用程序的命令如何引用另一个包含目录和库名称,这与之前版本的 allegro 不同:
Notice how the command to compile this application refers to another include directory and library names, which are different from the previous version of allegro:
g++ hello.cpp -o hello -I/usr/include/allegro5 -L/usr/lib -lallegro
这篇关于使用 allegro 5 和 g++ 编译 C++ 代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:使用 allegro 5 和 g++ 编译 C++ 代码


基础教程推荐
- 如何在 C++ 中初始化静态常量成员? 2022-01-01
- 常量变量在标题中不起作用 2021-01-01
- 这个宏可以转换成函数吗? 2022-01-01
- 如何检查GTK+3.0中的小部件类型? 2022-11-30
- 在 C++ 中计算滚动/移动平均值 2021-01-01
- C++结构和函数声明。为什么它不能编译? 2022-11-07
- 如何将 std::pair 的排序 std::list 转换为 std::map 2022-01-01
- 静态库、静态链接动态库和动态链接动态库的 .lib 文件里面是什么? 2021-01-01
- 如何通过C程序打开命令提示符Cmd 2022-12-09
- 我有静态或动态 boost 库吗? 2021-01-01