I just got a new HDD so I need to set up my allegro environment from scratch. I've done this before but I'm having trouble doing it again. Specifically, I want to statically link the 64-bit version of allegro 5.2.2 in Windows 8. In order I have:
Installed CodeBlocks with mingw pre-installed via codeblocks-16.01mingw-setup.exe from here.
Installed the allegro-mingw-gcc6.2.0-x64-static-5.2.2 library from here
Installed the allegro_deps-mingw-gcc6.2.0-x64-1.5.0 dependencies from here
Moved the pre-installed mingw to C:\MinGW.
Moved the above two libraries to C:\MinGW\allegro and C:\MinGW\allegro_deps respectively.
Linked all of the libraries and dependencies, defined ALLEGRO_STATICLINK, added the include directories and added the linker options "-static" and "-static-libgcc".
I can compile basic C programs and the compiler is locating all the files but it's having trouble finding the allegro functions in the library. I'm at a loss here. Here is my CodeBlocks project:
And here are the errors I'm getting:
<Add library="C:/MinGW/allegro/lib/liballegro_monolith-debug-static.a" />
This is the only allegro library that you really need to link. For some reason, the linker is not linking correctly to the allegro libraries. It could be because of ordering problems. You should link the windows libraries last, after the dependencies, and link the dependencies after allegro.
So my link order should look like this?
I'm still getting the same result. 47 errors, all pointing to undefined references.
I went through similar problems, but with 32-bit windows 7. There's a thread here:
https://www.allegro.cc/forums/thread/616089
The obvious differences between your setup and mine are that I seemed to need a couple of extra switches in the linker settings. Specifically
-static-libstdc++
-lpthread
Don't know if that will help you or not!
Post your build log. For some reason it's not linking.
You can try adding the libraries to linker options instead of link libraries. Specify libNAME.a with -lNAME in the linker options.
I tried a few more things and it turned out to be an issue with my compiler. If you use CodeBlocks with MinGW pre-installed, it will not properly link. And if you use the official mingw-get, you can't compile at all due to faulty installation via a SourceForge error.
The solution was to use TDM-GCC which gave me some annoying messages about the _FUNCTION_ macro but at least it compiles. On one last note, does anyone have a reccomendation of other simple C compilers compatible with CodeBlocks?
Allegro and its dependencies need to be compiled with the same compiler you're using to compile your program. Otherwise you can get some (not so) subtle bugs if not outright incompatibilities. I'm surprised your program compiled if you're using TDM-GCC for your program and the MSYS2 MinGW binaries for allegro and its dependencies. You might consider compiling it yourself, but the dependencies take a while to get right.
If mingw-get is not working, you should file a bug report with the mingwuser mailing list.
I may put out binaries for MinGW 5.3.0 and Allegro 5.2.2 here in a week or three. I need to sort out some issues with D3D and make a new release for my MinGW binaries first.