Static Linking Linux 4.4.2


I thought I had statically linked my game in Linux. I found out when I tested the binary files on another machine that I hadn't I guess playing on a machine that had Allegro 4.4.2 installed allows the binary to run.

You worked with me on my Windows link. I tried using the same list of files but obviously didn't work. Can you (or anyone) help me with the list of libraries needed to statically link my Linux program.


Edgar Reynaldo

On Linux, you want to use pkg-config to link allegro whether it is statically or dynamically.

Here are some various invocations of pkg-config you can use - the first two should work for you (at compile to object, and at link stage) :

`pkg-config --cflags --static allegro_monolith-debug-static-5`
`pkg-config --libs --static allegro_monolith-debug-static-5`
`pkg-config --Cflags allegro_monolith-5`
`pkg-config --libs allegro_monolith-5`

An example would be :

g++ -Wall -Wextra -Wshadow -g -o Main -I `pkg-config --cflags --static allegro_monolith-debug-static-5` Main.cpp Object1.cpp Etc.cpp `pkg-config --libs --static allegro_monolith-debug-static`


Thx Edgar. I don’t usually run from the prompt so I’ll have to see how that works with Eclipse IDE.


Edgar Reynaldo

You only need a command prompt to get the libraries you need to link to statically, and the compile flags for static allegro, like -DALLEGRO_STATICLINK.

Go to a terminal and type this :

echo `pkg-config --flags --libs --static allegro_monolith-debug-static-5`

Then take what you need from that and enter it into your eclipse project : I downloaded eclipse to try it out and these seem to be the proper places to put your commands :


Thread #617121. Printed from