Compiling allegro programs, under linux terminal
Phoxis

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

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)

bamccaig

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...

ldconfig

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/ld.so.conf 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.

MilesPrower

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.

Trezker

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

Thomas Fjellstrom

this is the (imo) proper set of commands:

debug:

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

release:

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

then run with ./program.

nutter

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`

Phoxis

Thanks for the replies. They would help me very much

Thread #597189. Printed from Allegro.cc