Hello,
I'm learning C++ and trying out some game libraries, so I decided to give Allegro a spin.
I've copied the example from http://wiki.allegro.cc/index.php?title=Allegro_5_Tutorial/Displays into a file and am trying to compile it with:
g++ main.cpp -o main -Wall -L/usr/local/include -L/usr/local/lib -lallegro_main -lallegro
(I have a makefile etc but this is what I've narrowed it down to.)
This compiles without errors, but when I run the executable I get:
dyld: Symbol not found: __al_mangled_main
Referenced from: /usr/local/lib/liballegro_main.5.0.dylib
Expected in: flat namespace
in /usr/local/lib/liballegro_main.5.0.dylib
Trace/BPT trap
What am I doing wrong? The necessary files should be present:
$ ls /usr/local/lib/liballegro.*
/usr/local/lib/liballegro.5.0.0.dylib
/usr/local/lib/liballegro.5.0.dylib
/usr/local/lib/liballegro.dylib
$ ls /usr/local/lib/liballegro_main.*
/usr/local/lib/liballegro_main.5.0.0.dylib
/usr/local/lib/liballegro_main.5.0.dylib
/usr/local/lib/liballegro_main.dylib
For C++, your main() function must be
int main(int argc, char **argv)
In particular,
int main(void)
will not work. This has to do with Allegro's name manging.
(EDIT: Ok, I see that the tutorial has this. Make sure you do too).
As an aside, you should set up and use pkg-config rather than passing the library flags to the compiler directly.
Check this: