2012-04-26 62 views
1

我收到了与下面链接中询问的人相同的错误。已经有了答案,但我到底该怎么做?感谢您的帮助如何强制OS X上的_al_mangled_main的“默认”可见性?

https://stackoverflow.com/a/5294039/1333847

EDIT1)这是代码:

#include "allegro5/allegro.h" 
#include "allegro5/allegro_image.h" 
#include "allegro5/allegro_native_dialog.h" 

int main(){ 

    ALLEGRO_DISPLAY *display = NULL; 
    ALLEGRO_BITMAP *image = NULL; 

    if(!al_init()) { 
     al_show_native_message_box(display, "Error", "Error", "Failed to initialize allegro!", 
           NULL, ALLEGRO_MESSAGEBOX_ERROR); 
     return 0; 
    } 

    if(!al_init_image_addon()) { 
     al_show_native_message_box(display, "Error", "Error", "Failed to initialize al_init_image_addon!", 
           NULL, ALLEGRO_MESSAGEBOX_ERROR); 
     return 0; 
    } 

    display = al_create_display(800,600); 

    if(!display) { 
     al_show_native_message_box(display, "Error", "Error", "Failed to initialize display!", 
           NULL, ALLEGRO_MESSAGEBOX_ERROR); 
     return 0; 
    } 

    image = al_load_bitmap("image.png"); 

    if(!image) { 
     al_show_native_message_box(display, "Error", "Error", "Failed to load image!", 
           NULL, ALLEGRO_MESSAGEBOX_ERROR); 
     al_destroy_display(display); 
     return 0; 
    } 

    al_draw_bitmap(image,200,200,0); 

    al_flip_display(); 
    al_rest(2); 

    al_destroy_display(display); 
    al_destroy_bitmap(image); 

    return 0; 
} 

这些都是错误的:

Undefined symbols for architecture x86_64: 
    "_al_show_native_message_box", referenced from: 
     __al_mangled_main in main.o 
    "_al_init_image_addon", referenced from: 
     __al_mangled_main in main.o 
ld: symbol(s) not found for architecture x86_64 
clang: error: linker command failed with exit code 1 (use -v to see invocation) 

EDIT2)使用此代码记录link to a code一切正常

+0

?如果您使用的是5.0.0以上的版本,这应该不成问题。 – Matthew 2012-04-26 22:13:54

+0

实际上我使用的是5.1(不稳定)分支。甚至试过了svn的5(稳定)版本(应该是最新的版本),仍然是一样的 – Markus 2012-04-26 22:15:47

+0

你应该在你的问题中包含你的错误消息的详细信息,以防万一有些不同。 (例如,忘记与-lallegro_main链接) – Matthew 2012-04-26 22:34:54

回答

3

Allegro 5是模块化的。经验法则是,如果您使用#include <allegro5/allegro_...>,则需要链接相应的库。你的情况:

_al_show_native_message_box:链接与-lallegro_native_dialog

_al_init_image_addon:链接与-lallegro_image您正在使用什么版本的快板

+0

实际上这工作! :)非常感谢你 – Markus 2012-04-27 07:28:08

+0

我节省了时间..谢谢 – 2013-03-02 01:28:14