Allegro.cc - Online Community

Allegro.cc Forums » Installation, Setup & Configuration » Noob for linking allegro .so libs to my project

This thread is locked; no one can reply to it. rss feed Print
Noob for linking allegro .so libs to my project
shinprog
Member #16,805
February 2018

Hi, I'm new here !
I'm running ubutnu 16.04LTS but i'm blocked with the installation of allegro.
I tried this tutorial but i'm unable to find where is located the .so libs for linking with code::blocks

https://emman31.wordpress.com/2013/01/21/ubuntu-12-04-installing-allegro-5-on-codeblocks/comment-page-1/

and if I try to run without linking , it display this :

-------------- Build: Debug in helloallegro (compiler: GNU GCC Compiler)---------------

g++ -L/usr/lib -o bin/Debug/helloallegro obj/Debug/main.o   
obj/Debug/main.o : Dans la fonction « main » :
/home/logan/programmation/cpp/allegro/helloallegro/main.cpp:8 : référence indéfinie vers « al_install_system »
/home/logan/programmation/cpp/allegro/helloallegro/main.cpp:13 : référence indéfinie vers « al_create_display »
/home/logan/programmation/cpp/allegro/helloallegro/main.cpp:19 : référence indéfinie vers « al_map_rgb »
/home/logan/programmation/cpp/allegro/helloallegro/main.cpp:19 : référence indéfinie vers « al_clear_to_color »
/home/logan/programmation/cpp/allegro/helloallegro/main.cpp:20 : référence indéfinie vers « al_flip_display »
/home/logan/programmation/cpp/allegro/helloallegro/main.cpp:21 : référence indéfinie vers « al_rest »
/home/logan/programmation/cpp/allegro/helloallegro/main.cpp:22 : référence indéfinie vers « al_destroy_display »
collect2: error: ld returned 1 exit status
Process terminated with status 1 (0 minute(s), 0 second(s))
0 error(s), 0 warning(s) (0 minute(s), 0 second(s))

I'm sorry, i'm really a noob with C++ configuration... I use python, that is easyest for installing libs ;D...
I searched during one hour but i found nothink...

Scooter
Member #16,799
January 2018

Go to settings in code:blocks.
Add directories for the linker to search.
If you need more info let us know.

Edgar Reynaldo
Major Reynaldo
May 2007
avatar

All three of you are wrong. :/

With Linux variants, you want to use pkg-config to compile and link your program.

That tutorial is out dated as well.

Quote:

Switch to branch 5.0 for the latest stable release
git checkout 5.0
Preparing for build
mkdir build; cd build

That's wrong. You want 'git checkout master' or 'git checkout 5.2.3'. 5.2.4 is coming out somewhat soon as well.

To compile, you add /usr/local/include to your search directory for the compiler.

To link, you add /usr/local/lib to your search directory for the linker.

To get the compiler options allegro was built with, use :

`pkg-config --cflags allegro5`

and to get the linker options you need to specify, use :

`pkg-config --libs allegro5`

So, a complete invocation with gcc would be :

gcc -Wall -Wextra -o runme `pkg-config --cflags allegro_monolith-5` main.c other.c `pkg-config --libs allegro_monolith-5`

You need to have pkg-config installed when you build allegro.

shinprog
Member #16,805
February 2018

H,thanks for your reply.
I didn't mentionned that i intalled allegro with PPA...
https://wiki.allegro.cc/index.php?title=Install_Allegro_from_Ubuntu_PPAs

should I try with github?

EDIT : problem solved thanks to +SiegeLord of the IRC canal
EDIT2 : change command
{"name":"1517688849.png","src":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/0\/9\/09417e2a2bfd3586f3be50e94c2d0a18.png","w":399,"h":360,"tn":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/0\/9\/09417e2a2bfd3586f3be50e94c2d0a18"}1517688849.png
1) do

pkg-config --libs allegro-5 allegro_font-5 allegro_image-5 allegro_ttf-5 allegro_color-5 allegro_primitives-5 allegro_audio-5 allegro_acodec-5 allegro_memfile-5 allegro_physfs-5

2) for me,it returns

-lallegro_image -lallegro_ttf -lallegro_font -lallegro_color -lallegro_primitives -lallegro_acodec -lallegro_audio -lallegro_memfile -lallegro_physfs -lallegro

3) go to project build options>Linker Settings>other linked options
4) paste the output and OK !!

Go to: