J'essaye de compiler un simple programme allegro5 sous Mac OSX 10.12 mais j'obtiens une erreur de symboles non définis. Voici la commande que je courais dans le terminalErreur lors de la compilation du programme allegro5 à l'aide de gcc sur osx
gcc main.c -o hello -I/usr/local/include/ -L/usr/local/lib -lallegro_main
Et voici mon code.
#include <stdio.h>
#include <allegro5/allegro.h>
int main(int argc, char **argv)
{
ALLEGRO_DISPLAY *display = NULL;
if(!al_init())
{
fprintf(stderr, "failed to initialize allegro!\n");
return -1;
}
display = al_create_display(640, 480);
if(!display)
{
fprintf(stderr, "failed to create display!\n");
return -1;
}
al_clear_to_color(al_map_rgb(0,0,0));
al_flip_display();
al_rest(10.0);
al_destroy_display(display);
return 0;
}
Voici l'erreur que je reçois
Undefined symbols for architecture x86_64:
"_al_clear_to_color", referenced from:
__al_mangled_main in main-b86b99.o
"_al_create_display", referenced from:
__al_mangled_main in main-b86b99.o
"_al_destroy_display", referenced from:
__al_mangled_main in main-b86b99.o
"_al_flip_display", referenced from:
__al_mangled_main in main-b86b99.o
"_al_install_system", referenced from:
__al_mangled_main in main-b86b99.o
"_al_map_rgb", referenced from:
__al_mangled_main in main-b86b99.o
"_al_rest", referenced from:
__al_mangled_main in main-b86b99.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Est-il possible que je ne l'ai pas installé correctement allegro? Je l'ai installé en utilisant homebrew selon les instructions wiki allegro. https://wiki.allegro.cc/index.php?title=Getting_Started#Mac_OS
Voilà à quoi sert '-lallegro_main'. Autant que je sache, le chemin de recherche et le chemin de la bibliothèque sont corrects. –
'lallegro' n'est pas la même chose que' lallegro_main'. 'lallegro' fournit la plupart des fonctionnalités de base,' lallegro_main' est juste pour la fonction principale (et je pense que c'est juste nécessaire pour MacOS). Bien que je ne vois pas de référence indéfinie pour 'al_init', je peux donc me tromper ici ... – rcorre
Le module' allegro_main' [dépend de] (http://liballeg.org/a5docs/trunk/getting_started.html) le module 'allegro'. Donc j'essaierais d'ajouter le drapeau '-lallegro' à votre appel' gcc' en plus de 'lallegro_main' – rcorre