2

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.

Renerte
  • 31
  • 5
  • Im guessing, that the library is 32 bit and you are trying to compile your code as 64 bit. The linker sees the library and goes nope, wrong architecture and moves on, try downloading the 64 bit lib files for allegro. – tom Jan 03 '15 at 17:00
  • @username_unavailable I don't think there are 64bit binaries to download, so I'll have to use 32bit compiler, or compile it myself. Big thanks for your help! I'd never think about the architecture of library. – Renerte Jan 03 '15 at 17:06

1 Answers1

0

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