To be able to link your allegro projects statically under Linux, you will have to build static versions of the allegro lib-files.
First, read this article on how to obtain the source code via SVN. I recommend you to install ALL of the dependencies to avoid later problems:
#apt-get install build-essential subversion cmake cmake-curses-gui xorg-dev libgl1-mesa-dev libglu-dev libpng-dev libcurl4-dev libfreetype6-dev libjpeg-dev libvorbis-dev libopenal-dev libphysfs-dev libgtk2.0-dev libasound-dev libpulse-dev libflac-dev libdumb1-dev
The documentation dependencies aren’t a must have, you can obtain the API-reference here.
Follow the wiki article until “Running CMake”. Here is where we change something. Instead of
ccmake -DCMAKE_INSTALL_PREFIX=/usr ..
ccmake -DSHARED=off -DCMAKE_INSTALL_PREFIX=/usr ..
This will configure it not to create shared objects but static versions, instead.
Alternatively you can start ccmake like in the article and toggle off the “SHARED” option after configuring.
Now you can hit c twice, then press g.
Now you are ready to build. Type
and wait for it to compile.
After that, you can finally install the libs by typing
If everything was successful, you will find at least a file called “liballegro-static.a” under /usr/lib/.
Well, that was it for the installation, now you want to compile your code and make it “portable”, right?
To handle the correct parameters to the compiler and linker, pkg-config is used.
To build a static version of your project that only includes allegro5/allegro.h, a typical command could look like this:
gcc -Wall source.c `pkg-config –libs –static allegro-static-5.1` -o program
NOTICE: I use allegro5.1, you will have to change the filenames according to your version!
Lets say, your code also uses the primitives-addon and you want to link statically against it, as well. Simply add the according
gcc -Wall source.c `pkg-config –libs –static allegro-static-5.1 allegro_primitives-static-5.1` -o program
Got it? You can use pkg-config to find out, what packages you have installed. Type
and press TAB for auto-completion. You should get a list of all installed allegro-libs.
That was pretty much it, I hope this helped a bit.