Xcode4 我该如何强制“执行”命令;“违约”;OSX上的_al_mangled_main的可见性?
我得到的错误与下面链接中询问的人相同。答案已经有了,但我该怎么做呢?谢谢你的帮助 edit1)这是代码:Xcode4 我该如何强制“执行”命令;“违约”;OSX上的_al_mangled_main的可见性?,xcode4,xcode4.3,allegro,allegro5,Xcode4,Xcode4.3,Allegro,Allegro5,我得到的错误与下面链接中询问的人相同。答案已经有了,但我该怎么做呢?谢谢你的帮助 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;
#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)
这些是错误:
#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)对于使用此代码的记录,一切都很好Allegro 5是模块化的。经验法则是,如果您使用的是
#include
,则需要链接到相应的库。就你而言:
\u al\u show\u native\u message\u box
:链接到-lallegro\u native\u对话框
\u al_init_image_addon
:链接到-lallegro_image
您使用的是什么版本的Allegro?如果您使用的是5.0.0以上的版本,这应该不会有问题。事实上,我使用的是5.1(不稳定)分支。甚至尝试了svn的5(稳定)版本(应该是最新的),但仍然是相同的,您应该在问题中包含错误消息的详细信息,以防出现不同的情况。(例如,忘记与-lallegro_main链接)@Matthew:编辑第一条消息以满足您的需要:)