liballeg/allegro_wiki

Cannot get Allegro working with MinGW Windows instructions

Closed this issue · 3 comments

I installed MinGW to C:\MinGW and copied Allegro's files over according to the documentation, but I can't get this to compile:

#include <allegro5/allegro5.h>

int main()
{
    al_init();
    return 0;
}

The error I get is:

C:\Users\Damien\Workspace\allegro>gcc hello.c -o hello -IC:/MinGW/include -LC:/MinGW/lib -lallegro
c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/ld.exe: C:\Users\Damien\AppData\Local\Temp\ccEbZBDg.o:hello.c:(.text+0x1e): undefined reference to `al_install_system'
collect2.exe: error: ld returned 1 exit status

Tangentially, MinGW does not come with pkg-config installed, so I'm kind of guessing that I have the right compiler and linker flags, but it looks like it should be pretty straightforward. It looks like the best way to get pkg-config installed is to use MSYS, but that's not part of Allegro's docs, and I wasn't having much better luck there anyway.

I also tried using backslashes and various alternatives for the final argument such as -lallegro-static and -lallegro_monolith, but to no avail.

This was tested on Windows 10 (Version 10.0.18362 Build 18362).

Which Allegro version did you download? Perhaps your compiler is 32 bit and you downloaded the 64 bit Allegro?

I'd recommend using https://www.msys2.org/ as your MinGW source. It is what's used to compile the official binaries, so compatibility will be best with that.

Allegro currently does not provide pkg-config on Windows.

+1, same issue. Tried re-installing MinGW and allegro.
Idk if I'm doing it right but I get the zip's contents and paste them in C:\MinGW (in the respective folders, include, lib and bin

image

I can import the library (throws an error if I remove the DLLs), but I can't call any function

@dradtke ld returned 1 because of iincompatible format. Your compiler and the compiler used to build the binaries aren't the same. The linker flags depend on the binary names of the binaries you downloaded. -lNAME to link libNAME.a .

@ItsYanko You're not linking to the native dialog addon. -lallegro_dialog .