1

I'm getting the same error as the person asking on the link bellow. There is already an answer, but how exactly do I do that? Thanks for any help

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

edit1) this is the code:

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

these are the errors:

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) for the record with this code link to a code everything works well

Community
  • 1
  • 1
Markus
  • 686
  • 1
  • 11
  • 18
  • What version of Allegro are you using? It shouldn't be a problem if you are using anything more recent than 5.0.0. – Matthew Apr 26 '12 at 22:13
  • actually I'm using the 5.1 (unstable) branch..even tried the 5 (stable) version from svn (which should be the most recent) and still the same – Markus Apr 26 '12 at 22:15
  • You should include your error message details in your question, in case something is different. (e.g., Forgetting to link with -lallegro_main) – Matthew Apr 26 '12 at 22:34
  • @Matthew: edited the first message to match your needs :) – Markus Apr 26 '12 at 23:42

1 Answers1

3

Allegro 5 is modular. Rule of thumb is if you are using an #include <allegro5/allegro_...>, then you need to link with the corresponding library. In your case:

_al_show_native_message_box: link with -lallegro_native_dialog

_al_init_image_addon: link with -lallegro_image

Matthew
  • 47,584
  • 11
  • 86
  • 98