Hello
I'm trying to compile my first allegro program. I thought the installation worked (according to the readme-file in allegro-4.9.12.zip i did: cmake, make, make install. all three commands gave no error messages).
When doing:
gcc hello.cpp
The compiler answers:
hello.cpp:1:21: error: allegro.h: No such file or directory
Do I need to add some parameters to the gcc-command (specify where the header file is)? The examples (which came in the allegro zip-file) are compiled - and working. So I guess, it can't be too difficult to compile my own...
Thanks for your help!
Try #include <allegro5/allegro.h> or #include <allegro5/allegro5.h>
Are you sure 4.9.12 is what you want? That's the unstable development branch for the next version of Allegro.
Most information you can find online and that you may be familiar with is for the old Allegro 4 (and earlier), which is nothing like the new Allegro. Just so you know.
Thank you, LennyLen! Unfortunately I've got another problem now. I don't know if that matters, but I'm running Mac OS X 10.5 on a G5.
My code:
#include <allegro5/allegro.h> int main(int argc, char* argv[]) { al_init(); return 0; } END_OF_MAIN()
Compilers opinion (started with: gcc hello.cpp):
Undefined symbols:
"___gxx_personality_v0", referenced from:
___gxx_personality_v0$non_lazy_ptr in cceozQSp.o
"_main", referenced from:
start in crt1.10.5.o
"_al_install_system", referenced from:
_mangled_main(int, char**)in cceozQSp.o
ld: symbol(s) not found
collect2: ld returned 1 exit status
Maybe you should try g++ instead of gcc?
The response of g++ is similar:
Undefined symbols:
"_main", referenced from:
start in crt1.10.5.o
"_al_install_system", referenced from:
_mangled_main(int, char**)in ccMAS6NT.o
ld: symbol(s) not found
collect2: ld returned 1 exit status
You need to put END_OF_MAIN() after the, well, end of main().
I did:
#include <allegro5/allegro.h> int main(int argc, char* argv[]) { al_init(); return 0; } END_OF_MAIN()
You need to link with `pkg-config allegro-4.9 --libs` or the OS X equivalent.
You need to link with `pkg-config allegro-4.9 --libs` or the OS X equivalent.
It's that in OS X.
tsk I just tried compiling an a5 program myself (allegro-4.9.12/examples/ex_acodec.c) and it took me 15 minutes of poking around to stumble across
gcc -s -O2 -Wall ex_acodec.c -o acodec `allegro5-config --libs` -lkcm_audio-4.9.12 -la5_acodec-4.9.12
to get it to find all necessary libs.
`pkg-config allegro-4.9 kcm_audio-4.9 a5_acodec-4.9 --libs`
So if I fiddle around with nm(1) long enough and sort which functions are in which libraries I can add to the docs?
So if I fiddle around with nm(1) long enough and sort which functions are in which libraries I can add to the docs?
The documentation already lists which functions go into which addon (or rather, which addon contains which function) - although that may be a recent addition. It should probably also give you the linker option or the name of the library to link with to get that particular addon.
Yes, that's a part of the documentation that should be updated. What's really missing right now is a "Using Allegro" type section that gives you the bird's-eye overview.
In your particular example, "ex_acodec" should be a hint that you need to link at least with a5_acodec (otherwise a glance at the source should tell you this), which depends on kcm_audio (pkg-config would pull that dependency in automatically, I think). So it shouldn't be that hard to figure out.
But again, a "Using Allegro" section is lacking at the moment.
I don't think it does. e.g., the font section has both font addons merged together (as it should). But it's not hard to figure out.
Each function should ultimately be marked with header file, library file, and in which Allegro version it first appeared (beginning with 5.0.0).
Thank you all! Just had to download pkg-config. My do-nothing-allegro-program compiles now, using:
g++ `pkg-config allegro-4.9 --libs` hello.cpp
To Evert (asking if I'm sure, that 4.9.12 is what I want): No actually I was/am not sure. I just downloaded the newest version from Sourceforge and tried to follow the instructions in the readme file. Since I have a working environment now, I think (at least I hope) I will be fine...
Thanks again to everyone!
pkg-config pulls in dependencies, so you only actually need to list the top one, e.g. `pkg-config --libs a5_acodec-4.9`
No actually I was/am not sure. I just downloaded the newest version from Sourceforge and tried to follow the instructions in the readme file. Since I have a working environment now, I think (at least I hope) I will be fine...
Ok. In that case, I applaud your determination and encourage you to ask lots of questions and give loads of feedback on the library and the documentation. The reason is that the library (and the API) are not stable yet and still subject to change , so if something is not designed well, it can still be fixed now.
The downside is that the documentation is incomplete and somewhat rough compared to Allegro 4's documentation and that subsequent releases may not be compatible: be prepared for having to change your code after you update to the next version of Allegro.