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++ 代码
基础教程推荐
- 初始化列表*参数*评估顺序 2021-01-01
- 为什么派生模板类不能访问基模板类的标识符? 2021-01-01
- 通过引用传递 C++ 迭代器有什么问题? 2022-01-01
- 为什么 RegOpenKeyEx() 在 Vista 64 位上返回错误代码 2021-01-01
- GDB 显示调用堆栈上函数地址的当前编译二进制文 2022-09-05
- 我应该对 C++ 中的成员变量和函数参数使用相同的名称吗? 2021-01-01
- 如果我为无符号变量分配负值会发生什么? 2022-01-01
- 为什么 typeid.name() 使用 GCC 返回奇怪的字符以及如 2022-09-16
- CString 到 char* 2021-01-01
- 非静态 const 成员,不能使用默认赋值运算符 2022-10-09
