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