Allegro.cc - Online Community

Allegro.cc Forums » Installation, Setup & Configuration » Xcode setup

This thread is locked; no one can reply to it. rss feed Print
Xcode setup
slycoder
Member #17,113
August 2019

I'm getting a crash when I launch my test app. I feel like its a config error but I'm not sure. I installed allegro with homebrew as suggested on the wiki. See below screenshots.

https://ibb.co/tDvJpRp
https://ibb.co/K7pf4hf
https://ibb.co/8jgW4WG
https://ibb.co/F6hMSR1

dyld: Symbol not found: __al_mangled_main
Referenced from: /usr/local/opt/allegro/lib/liballegro_main.5.2.dylib
Expected in: flat namespace
in /usr/local/opt/allegro/lib/liballegro_main.5.2.dylib
Program ended with exit code: 9

#SelectExpand
1#include <iostream> 2#include <allegro5/allegro.h> 3 4int main(int argc, const char * argv[]) { 5 6 ALLEGRO_DISPLAY *mainDisplay = NULL; 7 8 al_init(); 9 10 mainDisplay = al_create_display(600, 800); 11 12 al_clear_to_color(al_map_rgb(255, 0, 0)); 13 14 al_flip_display(); 15 16 al_rest(10); 17 18 al_destroy_display(mainDisplay); 19 20 // insert code here... 21 std::cout << "Hello, World!!\n"; 22 return 0; 23}

Edgar Reynaldo
Major Reynaldo
May 2007
avatar

slycoder
Member #17,113
August 2019

Is this different than the one in my first screenshot?

Peter Hull
Member #1,136
March 2001

Is your prog C++? - if so you have to be careful about your definition of main().
Can't check now but IIRC you need to lose the const from argv.
Anyway let me know if that helps otherwise I will look into it properly.

slycoder
Member #17,113
August 2019

@Peter That worked! And yes, it is c++. Do you know why it's so picky about the main args? I've never had an issue with any particular main args. These args were generated by the Xcode project template.

Peter Hull
Member #1,136
March 2001

It's something to do with mangling; Allegro #defines main to be _al_mangled_main and calls it from the real main which is in the addon. With C++, if you don't have the right types for your args, the symbol gets exported as __Z16_al_mangled_mainiPPKc so the linker can't find it.
This is in alosx.h.
I know effort went into making it as easy to use as possible but I don't really understand the details.

Go to: