• Create Account

## Allegro in CodeBlocks using MinGW - compiler/library version mismatch?

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

5 replies to this topic

### #1Lyrisath  Members

110
Like
0Likes
Like

Posted 07 July 2014 - 10:34 PM

A couple of nights ago I downloaded CodeBlocks, in the latest of many doomed attempts to resume programming since I dabbled a few years ago. Doomed, unfortunately, because I never seem to be able to get an IDE working with a library. This time I thought I'd ask for help, so with any luck the next problem I have will be one I've written myself. ;)

I downloaded CodeBlocks, and Allegro (5.0.10), and also MinGW (4.8.1) separately, and following this gloriously straightforward article - http://www.buildandgun.com/2013/09/creating-codeblocks-project-and-linking.html - to the best of my ability. So the code I have is the code on that page, saved as a .cpp file. But when I try to build and run it, I get the following:

||=== Build: Debug in Template (compiler: GNU GCC Compiler) ===|
..\..\Libraries\allegro-5.0.10-mingw-4.7.0\lib\liballegro-5.0.10-static-mt.a(d3d_display_formats.o):d3d_display_formats.cpp|| undefined reference to _Unwind_Resume'|
..\..\Libraries\allegro-5.0.10-mingw-4.7.0\lib\liballegro-5.0.10-static-mt.a(d3d_display_formats.o):d3d_display_formats.cpp|| undefined reference to _Unwind_Resume'|
..\..\Libraries\allegro-5.0.10-mingw-4.7.0\lib\liballegro-5.0.10-static-mt.a(d3d_display_formats.o):d3d_display_formats.cpp:(.eh_frame+0x63)||undefined reference to __gxx_personality_v0'|
||=== Build failed: 3 error(s), 0 warning(s) (0 minute(s), 2 second(s)) ===|

Now, I did try googling the key words from this (undefined reference to unwind resume/gxx personality), but I found the results to almost entirely impenetrable. As best I can figure, there's a mismatch between the version of MinGW that Allegro is expecting (4.7.0) and the version I have (4.8.1). But this is the newest version of Allegro, barring "potentially unstable" experimental builds.

Am I understanding the problem correctly?

Should I try to find the matching older version of MinGW and download that instead (and would I need to uninstall the current one)?

Or should I try one of the unstable builds of Allegro in the hopes that it might have caught up with the compiler version (though this cmake business always confuses me)?

### #2Wooh  Members

1088
Like
0Likes
Like

Posted 08 July 2014 - 02:44 AM

I don't know but maybe you it works better if you follow the instructions on the official wiki.

https://wiki.allegro.cc/index.php?title=Windows,_Code::Blocks_and_Allegro_5

981
Like
0Likes
Like

Posted 08 July 2014 - 02:59 AM

Unwind_resume is something from the exception handling in C++. Looks like the stdc++ library gets not linked. But .....

ld is no recursive linker. If you have the following commandline

<object files> -lstdc++ -lallegro

and liballegro needs functions from stdc++ they are missed.

<object files> -lallegro -lstdc++

will solve this. or

<object files> --start-group -lstdc++ -lallegro --end-group

For the libraries between --start-group and --end-group ld works like a recursive linker.

Edited by Tribad, 08 July 2014 - 02:59 AM.

### #4LennyLen  Members

5404
Like
1Likes
Like

Posted 08 July 2014 - 03:12 AM

I don't know but maybe you it works better if you follow the instructions on the official wiki.

https://wiki.allegro.cc/index.php?title=Windows,_Code::Blocks_and_Allegro_5

That page is outdated as it states the latest version of MinGW as 4.7.0.  There is no official binary for the latest version of MinGW.  Dynamic linking will not help either, as the problem is that the binaries are for a different version of MinGW.

Should I try to find the matching older version of MinGW and download that instead (and would I need to uninstall the current one)? Or should I try one of the unstable builds of Allegro in the hopes that it might have caught up with the compiler version (though this cmake business always confuses me)?

If you do decide to install the older version of MinGW to match the binaries you have then yes, you will need to uninstall the version you have now. The unstable (development) versions of Allegro do not come in a binary format, so you will have to build them yourself from source - you could also build the stable version from source as well so that it does match your MinGW version.

Building from source is not particularly difficult, but can take a while as you will need to download the tools (cmake, git etc) if you don't already have them and you will first need to build the dependencies. There is a complete guide to the process here.

### #5dejaime  Members

4157
Like
1Likes
Like

Posted 22 July 2014 - 02:19 PM

When I wrote that short tutorial I was using MinGW 4.8.1 myself; this shouldn't be the problem.

The obvious answer I could give you would be to download the Allegro binaries for MinGW 4.8.1, but I checked and they don't exist (these are community maintained, can't really complain).

The second obvious answer is telling you to compile Allegro 5.0.10 on your own instead of getting the binaries. Unfortunately Allegro is not an easy to build library, on the contrary, it takes a lot of time, needs some specific DirectX files and other libraries, a pain; go to this link if you want to give this a try.

Now, what you could really do is:

1 - Try adding the -fexceptions option to your compiler flags (right before pkg-config --cflags --libs allegro-5.0 allegro_primitives-5.0` ), it's worth a try.

2 - Go to the www.allegro.cc forums and ask if anyone has the binaries for 4.8.1. The only time I had gone there for help they were really helpful.

Just as a side note, both Allegro and MinGW have new versions, MinGW is on 4.9.0 while Allegro has its 5.1 out (with a new API). I'd recommend going with both new versions even though they are considered unstable.

### #6Lyrisath  Members

110
Like
0Likes
Like

Posted 25 July 2014 - 04:10 AM

For the benefit of anyone having the same problem and finding this via Google, after an enormously helpful exchange with the wonderful (and superhumanly patient) dejaime, we seem to have tracked down the source of this problem in this particular case: Code::Blocks was still using the version of MinGW that came bundled with it rather than the one I'd downloaded separately. Making sure it was pointing it at the latter instead fixed the problem.

Settings > Compiler... > Toolchain executables, and change "Compiler's installation directory" to the location of the separately-installed compiler's folder (in my case C:\MinGW rather than something under Code:Blocks' own folders).

Many thanks for the replies!

Edited by Lyrisath, 25 July 2014 - 04:11 AM.

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.