- Online Community Forums » Programming Questions » Compiling allegro programs, under linux terminal

This thread is locked; no one can reply to it. rss feed Print
Compiling allegro programs, under linux terminal
Member #10,005
July 2008

I have read the readme, and instructions, and have successfully compiled some allegro programs.

But will someone kindly, re describe how to do a command line compilation of a program written with allegro functions, using gcc?
How to include it in Fedora Eclipse ?
I tried to inscude it into fedora, linked the libs, but the -lalleg link is giving an error.
Please re describe the process. And let me know why are those links are used, and what they work for.

Cody Harris
Member #4,406
March 2004

try on linking instead of -lalleg, using adding `allegro-config --libs` (use the proper quotes, the one that's on the same key as ~. Check out allegro-config for other options (such as cflags, cppflags, and libs)

Homepage - Art (Photography)
I'm QBasicer on #allegro on Freenode.

Member #7,536
July 2006

IIRC, there is a command that "registers" libraries so that the linker can find them (according to the man page it seems like libraries are cached, likely for speed, and in order to find them the linker requires you to cache them). Until you do this the linker won't find the libraries you have installed since it was last executed. Something like ldconfig or something...


I haven't been using Linux enough recently to be sure, but that sounds right. :( Always check the man page before executing a command, however. ;) There appears to be a configuration file for ld (the linker) called /etc/ so you might want to check that out as well (to make sure the Allegro libraries are in one of the specified directories).

As Cody Harris said, there is a script in the Linux installation of Allegro that automatically outputs library options. It is called allegro-config. Therefore, you can use either back-tick syntax (`command`) or dollar-sign parenthesis syntax ($(command)) (depending on which shell you're using) to automatically insert the correct library options onto your command-line.

gcc options `allegro-config --libs` source_files
gcc options $(allegro-config --libs) source_files

IIRC, $(command) is the new "right" way, but `command` is compatible with more/older shells.

Member #9,986
July 2008

I always use
g++ main.c `allegro-config --libs`

assuming that your main source file is named main.c
then run it with ./a.out
hope that helps.

can't help you with fedora, though. sorry.

Member #1,739
December 2001

I use a Speedhack makefile, with a few modifications for profiling and debugging.

Thomas Fjellstrom
Member #476
June 2000

this is the (imo) proper set of commands:


gcc -W -Wall -ggdb3 -c file.c
gcc file.o -o program `allegro-config --libs`


gcc -W -Wall -c file.c
gcc -s file.o -o program `allegro-config --libs`

then run with ./program.

Thomas Fjellstrom - [website] - [email] - [Allegro Wiki] - [Allegro TODO]
"If you can't think of a better solution, don't try to make a better solution." -- weapon_S
"The less evidence we have for what we believe is certain, the more violently we defend beliefs against those who don't agree" --

Member #1,101
March 2001

Not sure if it adds much but if you want to link against allegro's debug library use:

gcc -W -Wall -ggdb3 -c file.c
gcc file.o -o program `allegro-config --libs debug`

Member #10,005
July 2008

Thanks for the replies. They would help me very much

Go to: