如何在 Fedora 中编译简单的 allegro 文件?

How to compile simple allegro file in Fedora?

我希望这不是一个重复的问题。我在我的 Fedora Linux 发行版上安装了 Allegro 5。我也安装了cmake。我的问题是我想要一个简单的例子来编译,这样我就可以学习更多的Allegro。

以下是一些命令:

[alanxoc3@alanxocomputer ~]$ locate allegro
/etc/allegro5rc
/usr/lib/liballegro.so.5.0
/usr/lib/liballegro.so.5.0.3
/usr/lib/liballegro_color.so.5.0
/usr/lib/liballegro_color.so.5.0.3
/usr/lib/liballegro_font.so.5.0
/usr/lib/liballegro_font.so.5.0.3
/usr/lib/liballegro_main.so.5.0
/usr/lib/liballegro_main.so.5.0.3
/usr/lib/liballegro_memfile.so.5.0
/usr/lib/liballegro_memfile.so.5.0.3
/usr/lib/liballegro_primitives.so.5.0
/usr/lib/liballegro_primitives.so.5.0.3
/usr/share/doc/allegro5
/usr/share/doc/allegro5/CHANGES-5.0.txt
/usr/share/doc/allegro5/CONTRIBUTORS.txt
/usr/share/doc/allegro5/LICENSE.txt
/usr/share/doc/allegro5/README.txt

我试过使用 gcc 编译它,但我不明白我将如何使用 cmake,似乎找不到好的教程。我的 g++ 命令如下所示:

[alanxoc3@alanxocomputer t00]$ g++ main.cpp
main.cpp:5:30: fatal error: allegro5/allegro.h: No such file or directory
compilation terminated.

这是我的源文件:

/**********************************************************
 * main.cpp - This program should create a test in the 
 * "Allegro" game programming language for c++.
 *********************************************************/
#include <allegro5/allegro.h>

int main (int argc, char *argv[])
{
   // Initialize a window
   allegro_init();
   install_keyboard();
   set_gfx_mode(GFX_AUTODETECT, 640, 480, 0 0);

   // Stall the program
   readkey();

   return 0;
}

END_OF_MAIN();

提前致谢,非常感谢您的建议:)。

糟糕!您忘记阅读文档了。

按照惯例,库的 "main" 包仅包含可再分发的二进制文件,例如您在问题中列出的二进制文件。通常还有一个 "development" 包,后缀为 -devel,其中包含构建使用该库的程序所需的头文件。

确实,the relevant page on the Allegro wikifedora allegro 的第一个 Google 结果)将 allegro-devel 列为可用软件包之一。这是该页面的引述:

The -devel packages are required to compile programs that use Allegro 5. The -debuginfo package should contain the debug symbols for more useful output in case of a crash. The other packages are the runtimes for the core library and the addons (required to run Allegro 5 programs).