I not sure if it's allegro issue or macOs issue itself.
Let's take sample code:
```
#include <allegro5/allegro5.h>
#include <allegro5/allegro_font.h>
#include <stdbool.h>
int main()
{
al_init();
al_install_keyboard();
ALLEGRO_TIMER* timer = al_create_timer(1.0 / 30.0);
ALLEGRO_EVENT_QUEUE* queue = al_create_event_queue();
ALLEGRO_DISPLAY* disp = al_create_display(320, 200);
ALLEGRO_FONT* font = al_create_builtin_font();
al_register_event_source(queue, al_get_keyboard_event_source());
al_register_event_source(queue, al_get_display_event_source(disp));
al_register_event_source(queue, al_get_timer_event_source(timer));
bool redraw = true;
ALLEGRO_EVENT event;
al_start_timer(timer);
while(1)
{
al_wait_for_event(queue, &event);
if(event.type == ALLEGRO_EVENT_TIMER)
redraw = true;
else if((event.type == ALLEGRO_EVENT_KEY_DOWN) || (event.type == ALLEGRO_EVENT_DISPLAY_CLOSE))
break;
if(redraw && al_is_event_queue_empty(queue))
{
al_clear_to_color(al_map_rgb(0, 0, 0));
al_draw_text(font, al_map_rgb(255, 255, 255), 0, 0, 0, "Hello world!");
al_flip_display();
redraw = false;
}
}
al_destroy_font(font);
al_destroy_display(disp);
al_destroy_timer(timer);
al_destroy_event_queue(queue);
return 0;
}
```
When I save file as hello.c and compile it with:
clang hello.c -o hello $(pkg-config allegro-5 allegro_main-5 allegro_font-5 --libs --cflags)
everything works, code compiles and runs.
But, when I save it as hello.cpp and compile with the same command
clang hello.cpp -o hello $(pkg-config allegro-5 allegro_main-5 allegro_font-5 --libs --cflags)
code compiles but macOs cannot link libraries:
./hello
dyld: Symbol not found: __al_mangled_main
Referenced from: /opt/homebrew/opt/allegro/lib/liballegro_main.5.2.dylib
Expected in: flat namespace
in /opt/homebrew/opt/allegro/lib/liballegro_main.5.2.dylib
zsh: abort ./hello
Any ideas why linker doesn't work with CPP code?