Allegro.cc - Online Community

Allegro.cc Forums » Allegro Development » allegro in xcode problem

This thread is locked; no one can reply to it. rss feed Print
allegro in xcode problem
The Master
Member #4,498
April 2004
avatar

I've just started allegro 5 programming on osx. That's new territory for me on multiple fronts.

I've gotten a program to build and run. I wrote it in c++ using the std libs in addition to a dynamically linked build of allegro 5. But I got a weird error in the debugger that goes:

Running…
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
sharedlibrary apply-load-rules all
Data Formatters temporarily unavailable, will re-try after a 'continue'. (Not safe to call dlopen at this time.)
(gdb) continue
Program received signal: “EXC_BAD_ACCESS”.
Data Formatters temporarily unavailable, will re-try after a 'continue'. (Not safe to call dlopen at this time.)
(gdb)

Any ideas as to what's going on?
The program uses the image and ttf addons, just for reference.

We can only do what we feel is right each moment as we live it.

Matthew Leverton
Supreme Loser
January 1999
avatar

Upgrade to 5.0.1.

The Master
Member #4,498
April 2004
avatar

didn't fix it.

Note, I didn't change the project settings or anything. I just added the new dylib files. and they say 5.0.1, not 5.0.0.

This is my file. I did it just as a test to get used to allegro 5.

#SelectExpand
1 2#include <iostream> 3#include <string> 4 5#include "allegro5/allegro.h" 6#include "allegro5/allegro_image.h" 7#include "allegro5/allegro_ttf.h" 8 9int main (int argc, const char *argv[]) { 10 11 ALLEGRO_DISPLAY *pDisplay = NULL; 12 ALLEGRO_TIMER *pTimer = NULL; 13 ALLEGRO_EVENT_QUEUE *pQueue = NULL; 14 ALLEGRO_EVENT e; 15 ALLEGRO_FONT *pFont = NULL; 16 bool bRedraw = false, bDone = false; 17 std::string strOrientationString; 18 19 al_init(); 20 al_install_keyboard(); 21 al_init_image_addon(); 22 al_init_font_addon(); 23 24 pDisplay = al_create_display( 640, 480 ); 25 if ( !pDisplay ) { 26 std::cout << "Can't create display!\n"; 27 return 0; 28 } 29 30 pFont = al_load_font( "arial.ttf", 5, 0 ); 31 if ( !pFont ) { 32 al_destroy_display( pDisplay ); 33 std::cout << "Can't load font!\n"; 34 return 0; 35 } 36 37 pTimer = al_create_timer( 1.0 / 60 ); 38 if ( !pTimer ) { 39 al_destroy_display( pDisplay ); 40 al_destroy_font( pFont ); 41 std::cout << "Can't create timer!"; 42 return 0; 43 } 44 45 pQueue = al_create_event_queue(); 46 al_register_event_source( pQueue, al_get_keyboard_event_source() ); 47 al_register_event_source( pQueue, al_get_timer_event_source( pTimer ) ); 48 al_register_event_source( pQueue, al_get_display_event_source( pDisplay ) ); 49 al_start_timer( pTimer ); 50 51 do { 52 53 al_wait_for_event( pQueue, &e ); 54 if ( e.type == ALLEGRO_EVENT_DISPLAY_ORIENTATION ) { 55 switch ( e.display.orientation ) { 56 case ALLEGRO_DISPLAY_ORIENTATION_0_DEGREES: strOrientationString = "0 Degrees"; break; 57 case ALLEGRO_DISPLAY_ORIENTATION_90_DEGREES: strOrientationString = "90 Degrees"; break; 58 case ALLEGRO_DISPLAY_ORIENTATION_180_DEGREES: strOrientationString = "180 Degrees"; break; 59 case ALLEGRO_DISPLAY_ORIENTATION_270_DEGREES: strOrientationString = "270 Degrees"; break; 60 case ALLEGRO_DISPLAY_ORIENTATION_FACE_UP: strOrientationString = "Face Up"; break; 61 case ALLEGRO_DISPLAY_ORIENTATION_FACE_DOWN: strOrientationString = "Face Down"; break; 62 } 63 } 64 if ( e.type == ALLEGRO_EVENT_DISPLAY_CLOSE ) { 65 bDone = true; 66 } 67 if ( e.type == ALLEGRO_EVENT_KEY_DOWN ) { 68 if ( e.keyboard.keycode == ALLEGRO_KEY_ESCAPE ) { 69 bDone = true; 70 } 71 } 72 if ( e.type == ALLEGRO_EVENT_TIMER ) { 73 bRedraw = true; 74 } 75 76 if ( bRedraw ) { 77 78 bRedraw = true; 79 al_clear_to_color( al_map_rgb( 0, 0, 0 ) ); 80 al_draw_text( pFont, al_map_rgb(255, 255, 255), 320, 240, ALLEGRO_ALIGN_CENTRE, strOrientationString.c_str() ); 81 82 } 83 84 } while ( !bDone ); 85 86 al_destroy_display( pDisplay ); 87 al_destroy_font( pFont ); 88 al_destroy_timer( pTimer ); 89 90 return 0; 91 92}

We can only do what we feel is right each moment as we live it.

Matthew Leverton
Supreme Loser
January 1999
avatar

You need to update the headers too.

The Master
Member #4,498
April 2004
avatar

what do you mean update the headers? I deleted all the headers and libraries from the relevant folders and installed the 5.0.1 files.

We can only do what we feel is right each moment as we live it.

Elias
Member #358
May 2000

Which libraries are you linking? Make sure you include at least:

  • allegro

  • allegro_main (especially this one seems to be missing)

  • allegro_ttf

  • allegro_font

  • allegro_image

--
"Either help out or stop whining" - Evert

The Master
Member #4,498
April 2004
avatar

yeah, that file is definitely linking. It's kinda annoying since allegro 4 had a straightforward tutorial on how to set up for different IDEs, and I haven't found anything for allegro 5. I realise thats because it's new. But for MSVS, it was really simple: open project properties, select linker, add lib files as additional inputs. Done.

Now xcode seems simple enough. Tell it what frameworks or dylibs you want to add, and it'll link them. Now it seems to compile and link fine. its when I run it that it gives these errors. and it seems to defy solution.

We can only do what we feel is right each moment as we live it.

Elias
Member #358
May 2000

Yeah, once we have proper Allegro frameworks things will be easier. Can than also have a monolith framework like for MSVC, which has all dependencies included. That should make it very easy to compile (add a single Allegro.framework to XCode) and distribute (the .app will have the framework included).

For now it sounds like you need to make sure the .dylib files (same as .dll/.so in Windows/Linux) are found. But I don't really know how that works in OSX.

--
"Either help out or stop whining" - Evert

The Master
Member #4,498
April 2004
avatar

if the files weren't being found, it wouldn't even build. It's saying it can't find __al_mangled_main, even though the allegro_main dylib is added. so I don't know what's going on. I mean, the samples and the demo's all link fine, no problem. and there's no real difference in code. I'm kinda at my wits end here.

We can only do what we feel is right each moment as we live it.

Elias
Member #358
May 2000

If you replace your code with that of one of the examples, say ex_draw_bitmap, does it also not work?

--
"Either help out or stop whining" - Evert

The Master
Member #4,498
April 2004
avatar

yep, exact same thing. which means its a problem with how i've configured this thing. would anyone be able to tell me how i set up an allegro project in xcode?

EDIT:
I know what WOULD be helpful is if one of the people who set up the build environment for the library could explain how they got the samples to compile in xcode. That would give me some clues as to how i can configure this thing. Also, I'm using xcode 3.2 - is that a problem? Should i upgrade to xcode 4?

We can only do what we feel is right each moment as we live it.

23yrold3yrold
Member #1,134
March 2001
avatar

XCode 4 is crap. I've been using it at work to iron out some problems for our game on the iPad2 and I don't have a big enough middle finger for Steve Jobs right now.

Allegro works on XCode 3.2. These guys walked me through it but it's damn messy at the moment. But it does work.

--
Software Development == Church Development
Step 1. Build it.
Step 2. Pray.

Elias
Member #358
May 2000

Well, the ios port of A5 is messy right now. The OSX port shouldn't be - we simply don't have anyone making binaries like we have for Windows.

[edit:] Actually, someone added Frameworks support to cmake for 5.0 already. In cmake, enable WANT_FRAMEWORKS. Then when you install you will get a set of frameworks.

In your own project now just select the allegro frameworks you want to use and it should work.

[edit2:] I'll try to make a script to build the frameworks so we can distribute OSX binaries. Just have to find the dependencies first... anyone know a place where you can download universal builds of freeptype, ogg vorbis and physfs?

Or maybe I should simply try and set everything to 32 bit instead of universal.

[edit3:] I described the steps here: http://wiki.allegro.cc/index.php?title=OSX,_Xcode_3,_Framework

--
"Either help out or stop whining" - Evert

The Master
Member #4,498
April 2004
avatar

Hey, this problem is still happening. It's still saying it can't find __al_mangled_main.

This is kinda irritating. MSVC works fine, but since I'm still living at home my dad won't allow ANY computer on the network without installing Norton Antivirus, and it won't let me run any program running Allegro. But that's just a problem with my computer. I am so going to transfer completely to linux, since I only like XP and more and more software is getting incompatible with it.

I tried compiling in the command prompt on my mac, and it still gave me the same thing. It compiles fine when I link all the appropriate libraries, but when I run it, it still complains about no __al_mangled_main. Is there some kind of setting that i need to configure? or is there a directive like END_OF_MAIN in allegro 4?

As a side note, why is it called mangled? Has it been maimed or something?

We can only do what we feel is right each moment as we live it.

Elias
Member #358
May 2000

No, main is a macro which is renamed to that and then gets called from allegro_main.dylib (which has the actual main() function). As Matthew said, it's important to use the right version of the headers though. Other than that, not sure - it works fine here. I even got it to work with frameworks - you can try that if you want, I described the steps on the wiki: http://wiki.allegro.cc/index.php?title=OSX,_Xcode_3,_Framework

Feel free to report if that's not working either (or just fix/enhance the steps in the wiki).

Not sure if you said already, but I was using XCode 3, the 10.5 SDK and gcc 4.2. Maybe Apple changed something for other versions.

--
"Either help out or stop whining" - Evert

Slartibartfast
Member #8,789
June 2007
avatar

The Master
Member #4,498
April 2004
avatar

still the same problem, even when following your tutorial.

man this is annoying.

EDIT: A thought occurs. I had to modify the process slightly, so as to include physfs in the build. I want physfs there so I can read from zip files. PhysFS was actually download in source form and built. Would that have an impact on allegro files? I'm still looking through the settings and comparing them with the build settings in the Allegro makefiles, since the examples and demo have no such trouble building and compiling. Is there some way i'm configuring these build settings differently and causing this?

We can only do what we feel is right each moment as we live it.

Trent Gamblin
Member #261
April 2000
avatar

Allegro 5 works perfectly fine on Xcode 4 except for the slowness of loading the Allegro project (which is present in 3.x too, but not as bad). That can be fixed by not enabling the examples anyway. Other than that, I've been using Xcode 4 since it's been released with only minor problems. Had a couple crashes while trying out new features (2-3 crashes), while annoying, for the amount of time I use it that's not that bad for a new product. Other than that, everything works fine and I think it's a great upgrade over 3.x.

The Master
Member #4,498
April 2004
avatar

Finally got it to work. I followed those instructions, but downloaded allegro 5.2 and didn't bother with physfs. now it works.

We can only do what we feel is right each moment as we live it.

Go to: