|
Compiling from the command line with gcc |
caomatto
Member #15,884
February 2015
|
What library should I pass as argument to gcc in addition to -lallegro in order to compile code in which appears a call to al_show_native_message_box? Thanks |
Edgar Reynaldo
Major Reynaldo
May 2007
|
You should have a lib file with the name dialog in it. Link to that one by using -lNAME where NAME is allegro_dialog.dll or something similar and the entire filename is liballegro_dialog.dll.a, or also libNAME.a. Or else link to the monolith. What distribution of allegro are you using? Or did you compile from source? The names vary slightly. My Website! | EAGLE GUI Library Demos | My Deviant Art Gallery | Spiraloid Preview | A4 FontMaker | Skyline! (Missile Defense) Eagle and Allegro 5 binaries | Older Allegro 4 and 5 binaries | Allegro 5 compile guide |
caomatto
Member #15,884
February 2015
|
I am on Ubuntu and I compiled from source, downloading the source through git. I typed gcc test.c -o test -lallegro -lallegro_dialog and it worked. Thanks! At page 1 of allegro-5.0.10-manual.pdf, there is a list of the addons:
Why can all those libraries be linked in gcc by passing their name prefixed with -l, except for the last one? For example the arguments -lallegro_image, -lallegro_primitives, -lallegro_memfile work, but the argument -lallegro_native_dialog doesn't and should be replaced by -lallegro_dialog. |
bamccaig
Member #7,536
July 2006
|
It is probably due to a naming convention confusion that occurred when they first added that addon and maybe nobody has bothered to fix it... I'm not sure. In general, there's no magic here. You can locate the Allegro libraries (shared objects) in your file system, named exactly as they are on your command line, except for having a lib prefix and so suffix per standard, as well as various symlinks with various degrees of version number (usually). sudo updatedb locate liballegro | grep /lib Rather than manually specifying linker flags, you should probably be using pkg-config to manage your linker flags for you. gcc -o test -Wall $(pkg-config --cflags allegro_5 allegro-dialog_5) \ test.c $(pkg-config --libs allegro_5 allegro-dialog_5) It's kind of surprising that you managed to compile and link without specifying custom header and library directories. Either you modified the install prefix or maybe Ubuntu includes /usr/local by default to make things easier (and potentially less secure)... -- acc.js | al4anim - Allegro 4 Animation library | Allegro 5 VS/NuGet Guide | Allegro.cc Mockup | Allegro.cc <code> Tag | Allegro 4 Timer Example (w/ Semaphores) | Allegro 5 "Winpkg" (MSVC readme) | Bambot | Blog | C++ STL Container Flowchart | Castopulence Software | Check Return Values | Derail? | Is This A Discussion? Flow Chart | Filesystem Hierarchy Standard | Clean Code Talks - Global State and Singletons | How To Use Header Files | GNU/Linux (Debian, Fedora, Gentoo) | rot (rot13, rot47, rotN) | Streaming |
|