Allegro Installation

565 views Asked by At

I've been trying to install allegro 5 into MSVS 2015 for 3 hours now, and have seen many tutorials, none of which helped me. I am using the code on the tutorial wiki to just make a screen.

#include "windows.h"
#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;
}

This is the error I get.

1>------ Build started: Project: Project7, Configuration: Debug Win32 ------
1>  Source.cpp
1>Source.obj : error LNK2019: unresolved external symbol _al_rest referenced in function _main
1>Source.obj : error LNK2019: unresolved external symbol _al_map_rgb referenced in function _main
1>Source.obj : error LNK2019: unresolved external symbol _al_create_display referenced in function _main
1>Source.obj : error LNK2019: unresolved external symbol _al_destroy_display referenced in function _main
1>Source.obj : error LNK2019: unresolved external symbol _al_flip_display referenced in function _main
1>Source.obj : error LNK2019: unresolved external symbol _al_clear_to_color referenced in function _main
1>Source.obj : error LNK2019: unresolved external symbol _al_install_system referenced in function _main
1>c:\users\jacob\documents\visual studio 2015\Projects\Project7\Debug\Project7.exe : fatal error LNK1120: 7 unresolved externals
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

Anything helps, thanks.

1

There are 1 answers

4
MishMash95 On

Unresolved external symbol implies a compile-time linker error. When you downloaded Allegro, it will have come with a collection of resources:

  • includes (.h/.hpp): These are header files which define what functions exist within the library, but will not actually contain the function code themselves.

  • libraries (.lib): These files contain pre-compiled code and need to be linked to your project.

  • dlls (.dll): DLLs aren't always used when you have other library resources, however they support runtime linkage and need to be distributed with your application in order for it to run correctly.

Linker Errors

You are most likely missing a link to your libraries. In Visual studio, you can add references to libraries by right clicking on your project in the solution explorer and navigating to the linker section. You will need to add the path to the "lib" folder in your allegro download. This can be done by adding the filepath to the additional library dependencies field.

Hope this helps!