Renerte
Renerte

Reputation: 31

Allegro: linker does not properly link libraries [Code::Blocks]

I have a problem with Allegro 5.0.10 libraries in Code::Blocks. They don't seem to link properly, because when I try to compile example from wiki:

#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;
}

Compiler gives series of errors like: D:/C++Dev/workspace/Obvi/Main.cpp:10: undefined reference to 'al_install_system'. I tried to fix it by linking using "other linker options". (-lallegro-5.0.10-monolith-static-mt), but then linker gives error: D:/TDM-GCC-64/bin/../lib/gcc/x86_64-w64-mingw32/4.9.2/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find -lallegro-5.0.10-monolith-static-mt. I added "Search Directories": libs for linker, and includes for compiler. In build log I also found: D:/TDM-GCC-64/bin/../lib/gcc/x86_64-w64-mingw32/4.9.2/../../../../x86_64-w64-mingw32/bin/ld.exe: skipping incompatible D:\C++Dev\libs\allegro-5.0.10-mingw-4.7.1-tdm\lib/liballegro-5.0.10-monolith-static-mt.a when searching for -lallegro-5.0.10-monolith-static-mt which tells that linker finds library, but for some reason ignores it.

Upvotes: 2

Views: 1626

Answers (1)

J&#225;nos Simonyi
J&#225;nos Simonyi

Reputation: 16

Did you link the -lalleg library? Go to Settings->Compiler->Linker settings->Other linker options and type -lalleg.

Upvotes: 0

Related Questions