Allegro.cc - Online Community

Allegro.cc Forums » Installation, Setup & Configuration » Can't initialize allegro

This thread is locked; no one can reply to it. rss feed Print
Can't initialize allegro
yasyaserov
Member #16,760
October 2017

Hello, I've been trying to compile and run using msys2. I followed instructions in the wiki (with additional stuff in forums for cmake part) and I finally installed allegro(I think). But the problem is after compiling. I've used:

gcc -Wall main.c `pkg-config --cflags --libs allegro-5 allegro_main-5`

and

gcc -c main.c
gcc main.o -lallegro -o a

but after I run the program, it gives allegro failed to initialize error(basically al_init() returns false)

I really don't know what to do :/

SiegeLord
Member #7,827
October 2006
avatar

Can you add this code to your main function (before al_init) and see what it prints?

uint32_t version = al_get_allegro_version();
int major = version >> 24;
int minor = (version >> 16) & 255;
int revision = (version >> 8) & 255;
int release = version & 255;

printf("Library version: %d.%d.%d.%d\n", major, minor, revision, release);
printf("Header version: %s\n", ALLEGRO_VERSION_STR);

It it prints different things, then something went wrong when you installed Allegro (via make install). Can you tell us what commands you used for cmake and make?

"For in much wisdom is much grief: and he that increases knowledge increases sorrow."-Ecclesiastes 1:18
[SiegeLord's Abode][Codes]:[DAllegro5]:[RustAllegro]

beoran
Member #12,636
March 2011

l guess that you have another, older version of allegro somewhere on your system that gets linked in at run time. On linux, you could try ldd program to see what kibraries will be linked at runtime.

yasyaserov
Member #16,760
October 2017

Library Version: 5.2.2.1
Header Version: 5.2.4 (GIT)

Yeah these are different.

I probably need to uninstall MSYS2 and reinstall everything.

What am I supposed to after installing mingw toolchain and dependencies.

I did:

git clone https://github.com/liballeg/allegro5.git

git checkout 5.0

mkdir build_allegro_monolith
cd build_allegro_monolith
cmake \
-G"MSYS Makefiles" \
-DCMAKE_SYSTEM_PREFIX_PATH=/mingw64/x86_64-w64-mingw32/ \
-DWANT_MONOLITH=on \
-DSHARED=off \
../allegro5

make
make install

but I am guessing this is wrong, eh?

Edgar Reynaldo
Major Reynaldo
May 2007
avatar

SiegeLord
Member #7,827
October 2006
avatar

Somehow you have a separate installation of Allegro. Find where it is, and remove it. You can use the http://www.dependencywalker.com/ to see which DLLs your binary is loading (very useful if you plan to distribute your binary to other computers, so you include everything).

Also... yes, you want to do git checkout master, or, perhaps, git checkout 5.2.3.0 if you want the most recent release.

"For in much wisdom is much grief: and he that increases knowledge increases sorrow."-Ecclesiastes 1:18
[SiegeLord's Abode][Codes]:[DAllegro5]:[RustAllegro]

Go to: