Reputation: 11
I've got some problems getting up Allegro 5 library in Visual Studio 2017. In most cases i'm getting linker errors (unknown/unrecognized external types). I said in most cases, because this 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;
}
source:https://wiki.allegro.cc/index.php?title=Allegro_5_Tutorial/Displays
compiles as usual without errors and runs as expected. But this code:
#include "allegro5/allegro.h"
#include "allegro5/allegro_image.h"
#include "allegro5/allegro_primitives.h"
int main(int argc, char **argv){
ALLEGRO_DISPLAY *display = NULL;
ALLEGRO_DISPLAY_MODE disp_data;
al_init(); // I'm not checking the return value for simplicity.
al_init_image_addon();
al_init_primitives_addon();
al_get_display_mode(al_get_num_display_modes() - 1, &disp_data);
al_set_new_display_flags(ALLEGRO_FULLSCREEN);
display = al_create_display(disp_data.width, disp_data.height);
al_rest(3);
al_destroy_display(display);
return 0;
}
source: the same, next tutorial.
gets me 3 errors in linker. Many other codes do as well with various numbers of errors in linker.
In this prticular case are the errors as folows:
Error code Description
LNK2019 Unrecognized external symbol __imp__al_init_image_addon reffered in function _main
LNK2019 Unrecognized external symbol __imp__al_init_primitives_addon reffered in function _main
LNK1120 Number of unrecognized external types:2
I've read that Allegro has some dependencies in freetype, so i installed it using NuGet(project pakage manager), the same way as Allegro. I'm new to Visual Studio, so if you have a possible solution, please explain step by step (and, if you are capable of it, please explain, so I can learn something new)
If you need something to find the solution, just ask and explain how can i get it.
Thanks a lot in advance.
Upvotes: 0
Views: 973
Reputation: 335
Glad you solved it. For the record, the addon libraries are not linked by default in the Nuget Package for VS. After installing the Allegro 5 Nuget package for your solution, right click on the project properties and select Allegro5 from the menu on the left. Go to addon libraries, and enable the addons you're using. Easy peasy.
Upvotes: 1
Reputation: 11
Yep, I'm just stupid.
I'm sorry for all the trouble I've caused.
It was because I didn't know that I have to enable the modules in project properties under Allegro 5 tab. Now I've got it up and running.
I'm very sorry for bothering you.
Upvotes: 1