Allegro.cc - Online Community

Allegro.cc 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
Phoxis
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
avatar

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.

bamccaig
Member #7,536
July 2006
avatar

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

Trezker
Member #1,739
December 2001
avatar

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

Thomas Fjellstrom
Member #476
June 2000
avatar

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.

--
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" -- https://twitter.com/neiltyson/status/592870205409353730

nutter
Member #1,101
March 2001
avatar

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
Member #10,005
July 2008

Thanks for the replies. They would help me very much

Go to: