Native message boxes error
Tenderenden

Hi
When I try to run my simple program that should just open message box with greeting I get this error:
LNK2019:unresolved external symbol _imp_al_show_native_message_box referenced in function _main
Where might be the problem?

EDIT: I forgot to mention that I'm using Visual Studio 15 and Allegro 5.2.2 installed via NuGet.

My code:

#SelectExpand
1#include <stdio.h> 2#include <allegro5/allegro.h> 3#include <allegro5/allegro_native_dialog.h> 4#include <iostream> 5using namespace std; 6int main() { 7 8 ALLEGRO_DISPLAY *display = NULL; 9 10 if (!al_init()) { 11 cout<<"failed to initialize allegro!\n"; 12 return -1; 13 } 14 15 display = al_create_display(1280, 720); 16 if (!display) { 17 cout<<"failed to create display!\n"; 18 return -1; 19 } 20 al_clear_to_color(al_map_rgb(100, 15, 0)); 21 al_flip_display(); 22 al_rest(5.0); 23 al_show_native_message_box(display, "Dialog", "Epic Win!", "Nice one you got there!\nAllegro sucesfully created pop-up window", NULL, NULL); 24 al_destroy_display(display); 25 return 0; 26}

Eric Johnson

I think you have to initialize the native dialog addon before using it.

Something like this:

if (!al_init_native_dialog_addon()) {

  cout << "Failed to initialize native dialog addon!\n";

  return -1;
}

Tenderenden

@Eric Johnson
I don't think that's it. Now when I used it I get two errors like that :D

What is more, in Allegro5 manual I found this:
al_show_native_message_box may be called without Allegro being installed. This is useful to report an error to initialise Allegro itself.

So I guess if you don't have to initialise main allegro library, you don't have to initialise that as well.

BTW Thanks for quick response ;)

Eric Johnson

Huh, I could have sworn it was required. My mistake. :P

Are you linking with allegro_dialog-5? I compiled on Linux like this and your code worked:

g++ -Wall -o dialog dialog.c $(pkg-config --libs allegro-5 allegro_dialog-5)

Tenderenden

Oh my God!

Thank you so much!
I thought that NuGet will do everything for me in here. Now it is working ;D

For anyone having same issue:
I simply just went to my project properties -> Allegro 5 -> Addons and then choose "Yes" in Dialog Addon.
[Screenshot in attachment]

Eric Johnson

Glad it's working for you now. :)

Thread #616758. Printed from Allegro.cc