GUIDE: Allegro on Fedora (Linux) with KDevelop
Josh1billion

Through my old topic, I was able to get the help I needed to set this up.. so I've decided to simplify this entire process into a guide.

GOAL: Installing Allegro on Fedora Core and setting up a simple "Hello World" project in KDevelop.

PREREQUISITES: This guide will assume that you already have KDevelop installed and Fedora's package manager "yum" installed. Unless your Fedora installation was a slim one, you should already have both of these included. Particularly, I think yum is included on all Fedora systems by default. I'm not entirely sure on that, though. You can run yum by going to a terminal and typing "yum" (without quotes). On GNOME, KDevelop will be in your Applications menu, under Programming, as "KDevelop: C/C++"

Part 1: Installing Allegro (skip this if you already installed Allegro)

Step 1. Open up a terminal (new to Linux? Terminal can be found in Applications->System Tools). Type "yum install allegro" Once that's installed, type "yum install allegro-devel" Then "yum install allegro-tools" for a few extra tools that may come in handy. You should also install AllegroOGG in case you try to play a game that uses it-- type "yum install AllegroOGG" and in case you want to include it in your own apps later on, type "AllegroOGG-devel"

Step 2 (optional). Test this to make sure it's installed correctly: in a terminal, type "allegro-config --libs" This will output something like this (it may not look exactly the same, but this is just an example):

-L/usr/lib -Wl,--export-dynamic -lalleg-4.2.1 -lalleg_unsharable

If it says "allegro-config: command not found", that means that you haven't installed Allegro correctly. Go back to step one and try again.

Ok, so now Allegro should be installed successfully at this point.

Part 2: Starting a new project in KDevelop

Step 1. Run "KDevelop: C/C++". If you're using GNOME, it is located in Applications->Programming. Notice that there are many different versions of KDevelop listed there-- make sure you use "C/C++", not "KDE/C++"

Step 2. Under the Project menu, go to New Project. Under the C++ category, choose Simple Hello world program, as shown in thie screenshot:
[url=http://img381.imageshack.us/my.php?image=newprojectkq6.png][img]http://img381.imageshack.us/img381/9963/newprojectkq6.th.png[/img][/url]

Type in a name for the project ("helloworld" for example), etc.

Part 3: Entering the Code

Step 1. Once you have the code on-screen, remove it and copy+paste this ALL of this (including END_OF_MAIN()) over it instead:

int main(void)
{
    allegro_init();
    set_gfx_mode(GFX_AUTODETECT_WINDOWED, 640, 480, 0, 0);
    install_keyboard();
    textout_ex(screen, font, "Hello World!", 1, 1, 10, -1);
    while(!key[KEY_ESC]);
    allegro_exit();
    return 0;
}END_OF_MAIN()

Part 4: Linking the Allegro libraries into the project

Step 1. On the way-right edge of the KDevelop window, you'll find Documentation, Code Snippets, and Automake Manager listed vertically. Odd that they would be hidden over there.. hard to find if you're not looking just right. Anyway, click the "Automake Manager" tab to bring up the automake manager side panel. In the bottom pane of the side panel, you will see two entries: "(Header in noinst)" and "[name of your project]". Right-click your project's name (shown in the Step 5 screenshot as "utd_test" because that's my project's name), and choose Options.

Step 2. Go to the Libraries tab. Now, we're going to click Add and type in the filename of the Allegro library. But before we do that, we have to know what the filename of the library is. So open up a terminal and type this command, the same command we typed earlier:
allegro-config --libs

It should output something like this, a list of Allegro libraries.

-L/usr/lib -Wl,--export-dynamic -lalleg-4.2.1 -lalleg_unsharable

Step 3. Copy and paste the name of the library that looks like "-lalleg-4.2.1" into that dialog that pops up when you press the Add button. Depending on your version, it could be -lalleg-4.3 or something else, so don't use what mine says; use what yours said when you typed the above command, instead. The other libraries listed seem irrelevant and link fine for me without, but if you later run into problems compiling/linking your project, try copying and pasting them in there as well. Others have recommended pasting in the entire line that "alleg-config --libs" outputs, but for me that produces an error with the "-Wl,--export-dynamic" part which I later had to remove from there. Click "OK" on all the windows when you're ready and proceed...

The libraries should now be linked, so we'll build the project and run it.

Part 5: Building the project and executing it

Step 1. In the main KDevelop window, on the menu, go to Build and choose Build Project (or press F8). The project should compile and link as normal, and say Success when done. Good! Now you can run the game by going to Build->Execute Program (or press Shift+F9).

[URL=http://img358.imageshack.us/my.php?image=librariesjq9.png][IMG]http://img358.imageshack.us/img358/4655/librariesjq9.th.png[/IMG][/URL]

If it didn't compile fine, you'll have to re-do a few things. Here's a section on how to fix that...

Extra: Troubleshooting compiling problems

.Problem: I'm getting errors like these when compiling:

/home/Josh/Projects/helloworld/src/helloworld.cpp:5: undefined reference to `_install_allegro_version_check'
/home/Josh/Projects/helloworld/src/helloworld.cpp:6: undefined reference to `set_gfx_mode'
/home/Josh/Projects/helloworld/src/helloworld.cpp:7: undefined reference to `install_keyboard'
/home/Josh/Projects/helloworld/src/helloworld.cpp:8: undefined reference to `font'
/home/Josh/Projects/helloworld/src/helloworld.cpp:8: undefined reference to `screen'
/home/Josh/Projects/helloworld/src/helloworld.cpp:8: undefined reference to `textout_ex'
/home/Josh/Projects/helloworld/src/helloworld.cpp:10: undefined reference to `allegro_exit'
/home/Josh/Projects/helloworld/src/helloworld.cpp:9: undefined reference to `key'

.Solution: These errors appear when you don't have the Allegro library linked. Are you sure you linked it correctly? Go back to Part 4 of the guide and try doing that over. If that doesn't work, maybe you linked the wrong library? Try linking ALL of the libraries that the "allegro-config --libs" outputs. This error also happened to me after I had manually edited the Makefile (which was a bad idea), so I had to start a new project and try again (Part 2 of the guide).

.Problem: I'm getting "gmake[2]: *** No rule to make target `[Allegro library name]', needed by '[project name]'."
.Solution: You must have entered the Allegro library name in incorrectly. Make sure there's a dash and an L before it, like "-l"

Let me know if this guide helped you. :)

CGamesPlay

You actually have incorrect information there. You should modify it a bit so that you use the information about AM_PATH_ALLEGRO, which you can find in this article.

[append]

Sorry it was kinda hard to google, as the page title was off. I switched it to a proper title, and I'll review and edit your article when I get some spare time.

I may take what you have and merge it into that article, since your stuff will be more up-to-date and/or I may have noticed something when I wrote that originally.

Thread #592235. Printed from Allegro.cc