来自命令行OSX的Allegro 5

时间:2014-05-12 10:29:01

标签: c++ macos allegro5

虽然我是编程新手,但我可以使用C ++,并且正在尝试学习一些基本的Allegro 5以及一些可以在Allegro Wiki上找到的教程。我从命令行使用Mac OSX 10.7.5(但我正在考虑尝试使用Xcode)。 使用g ++(或使用clang ++)编译this tutorial project(您可以在我的帖子末尾找到完整的源代码)时得到的错误代码是:

$ g++ tutorial.cxx -lallegro -lallegro_main
Undefined symbols for architecture x86_64:
"_al_init_image_addon", referenced from:
  __al_mangled_main in ccdwG70k.o
"_al_show_native_message_box", referenced from:
  __al_mangled_main in ccdwG70k.o
ld: symbol(s) not found for architecture x86_64
collect2: ld returned 1 exit status

并且,不使用-lallegro和-lallegro_main,

$ g++ tutorial.cxxUndefined symbols for architecture x86_64:
"_al_create_display", referenced from:
  __al_mangled_main in ccWL3qZZ.o
"_al_destroy_bitmap", referenced from:
  __al_mangled_main in ccWL3qZZ.o
"_al_destroy_display", referenced from:
  __al_mangled_main in ccWL3qZZ.o
"_al_draw_bitmap", referenced from:
  __al_mangled_main in ccWL3qZZ.o
"_al_flip_display", referenced from:
  __al_mangled_main in ccWL3qZZ.o
"_al_init_image_addon", referenced from:
  __al_mangled_main in ccWL3qZZ.o
"_al_install_system", referenced from:
  __al_mangled_main in ccWL3qZZ.o
"_al_load_bitmap", referenced from:
  __al_mangled_main in ccWL3qZZ.o
"_al_rest", referenced from:
  __al_mangled_main in ccWL3qZZ.o
"_al_show_native_message_box", referenced from:
  __al_mangled_main in ccWL3qZZ.o
"_main", referenced from:
  start in crt1.10.6.o
 (maybe you meant: __al_mangled_main)
ld: symbol(s) not found for architecture x86_64
collect2: ld returned 1 exit status

但是在编译this other tutorial时没有问题。

你能解释一下第一个程序有什么问题吗?任何建议将不胜感激。这是“tutorial.cxx”的代码,来自第一个链接:

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

int main(int argc, char **argv){

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;
}

非常感谢,

乔治

0 个答案:

没有答案