Allegro 4.9.16 binaries and Code::Blocks/MinGW problem
NickWright

Hello Forum. I was wondering if anybody could help me out? I've downloaded the Allegro 4.9.16 MinGW32 binaries from allegro5.org, but I'm having trouble using them with Code::blocks. I did the following things:

1) Unpack the binaries to d:\Coding\allegro-4.9.16-mingw-bin\

2) Downloaded the dx9 for mingw from the same place and unpacked them into the MinGW directory

3) Added the allegro-4.9.16-mingw-bin\include and allegro-4.9.16-mingw-bin\lib paths to the Compiler and Linker search directories respectively

4) In the Project->Build Options->Linker settings->link libraries list, I added all the '.a' files from allegro-4.9.16-mingw-bin\lib to the list

5) Tried to compile the following code

#SelectExpand
1#define ALLEGRO_STATICLINK 1 2#include <allegro5/allegro.h> 3 4int main(void) 5{ 6 al_init(); 7 8 ALLEGRO_DISPLAY *display = al_create_display(640, 480); 9 10 al_clear_to_color(al_map_rgb(0, 150, 0)); 11 12 al_flip_display(); 13 14 al_rest(5); 15 16 return 0; 17} 18END_OF_MAIN()

and got the following errors (it's a big list so I've only included the first lot)

#SelectExpand
1C:\Users\Nick\Desktop\temp\test\main.cpp||In function `int _mangled_main()':| 2C:\Users\Nick\Desktop\temp\test\main.cpp|8|warning: unused variable 'display'| 3D:\Coding\allegro-4.9.16-mingw-bin\lib\liballegro-static-4.9.16.a(wnewsys.c.obj)||In function `win_get_path':| 4C:\Documents and Settings\Trent Gamblin\4.9.16\src\win\wnewsys.c|448|undefined reference to `GetModuleFileNameExA@16'| 5C:\Documents and Settings\Trent Gamblin\4.9.16\src\win\wnewsys.c|407|undefined reference to `GetModuleFileNameExA@16'| 6D:\Coding\allegro-4.9.16-mingw-bin\lib\liballegro-static-4.9.16.a(wnewsys.c.obj)||In function `win_shutdown':| 7C:\Documents and Settings\Trent Gamblin\4.9.16\src\win\wnewsys.c|201|undefined reference to `timeEndPeriod@4'| 8D:\Coding\allegro-4.9.16-mingw-bin\lib\liballegro-static-4.9.16.a(wnewsys.c.obj)||In function `win_initialize':| 9C:\Documents and Settings\Trent Gamblin\4.9.16\src\win\wnewsys.c|157|undefined reference to `timeBeginPeriod@4'| 10D:\Coding\allegro-4.9.16-mingw-bin\lib\liballegro-static-4.9.16.a(wtime.c.obj)||In function `al_init_timeout':| 11C:\Documents and Settings\Trent Gamblin\4.9.16\src\win\wtime.c|147|undefined reference to `timeGetTime@0'| 12C:\Documents and Settings\Trent Gamblin\4.9.16\src\win\wtime.c|144|undefined reference to `timeGetTime@0'| 13D:\Coding\allegro-4.9.16-mingw-bin\lib\liballegro-static-4.9.16.a(wtime.c.obj)||In function `al_win_init_time':| 14C:\Documents and Settings\Trent Gamblin\4.9.16\src\win\wtime.c|102|undefined reference to `timeGetTime@0'| 15D:\Coding\allegro-4.9.16-mingw-bin\lib\liballegro-static-4.9.16.a(wtime.c.obj)||In function `low_res_current_time':| 16C:\Documents and Settings\Trent Gamblin\4.9.16\src\win\wtime.c|49|undefined reference to `timeGetTime@0'| 17D:\Coding\allegro-4.9.16-mingw-bin\lib\liballegro-static-4.9.16.a(d3d_disp.cpp.obj)||In function `d3d_generate_display_format_list':| 18C:\Documents and Settings\Trent Gamblin\4.9.16\src\win\d3d_disp.cpp|556|undefined reference to `_Unwind_Resume'| 19C:\Documents and Settings\Trent Gamblin\4.9.16\src\win\d3d_disp.cpp|555|undefined reference to `_Unwind_Resume'| 20D:\Coding\allegro-4.9.16-mingw-bin\lib\liballegro-static-4.9.16.a(d3d_disp.cpp.obj)||In function `al_d3d_init_display':| 21C:\Documents and Settings\Trent Gamblin\4.9.16\src\win\d3d_disp.cpp|858|undefined reference to `Direct3DCreate9@4'| 22D:\Coding\allegro-4.9.16-mingw-bin\lib\liballegro-static-4.9.16.a(d3d_disp.cpp.obj):d3d_disp.cpp:(.eh_frame+0x12)||undefined reference to `__gxx_personality_v0'| 23D:\Coding\allegro-4.9.16-mingw-bin\lib\liballegro-static-4.9.16.a(wgl_disp.c.obj)||In function `init_temp_context':| 24C:\Documents and Settings\Trent Gamblin\4.9.16\src\win\wgl_disp.c|152|undefined reference to `wglCreateContext@4'| 25C:\Documents and Settings\Trent Gamblin\4.9.16\src\win\wgl_disp.c|159|undefined reference to `wglMakeCurrent@8'| 26C:\Documents and Settings\Trent Gamblin\4.9.16\src\win\wgl_disp.c|162|undefined reference to `wglDeleteContext@4'| 27D:\Coding\allegro-4.9.16-mingw-bin\lib\liballegro-static-4.9.16.a(wgl_disp.c.obj)||In function `is_wgl_extension_supported':| 28C:\Documents and Settings\Trent Gamblin\4.9.16\src\win\wgl_disp.c|106|undefined reference to `glGetString@4'| 29C:\Documents and Settings\Trent Gamblin\4.9.16\src\win\wgl_disp.c|109|undefined reference to `wglGetProcAddress@4'| 30D:\Coding\allegro-4.9.16-mingw-bin\lib\liballegro-static-4.9.16.a(wgl_disp.c.obj)||In function `setup_gl':| 31C:\Documents and Settings\Trent Gamblin\4.9.16\src\win\wgl_disp.c|91|undefined reference to `glViewport@16'| 32C:\Documents and Settings\Trent Gamblin\4.9.16\src\win\wgl_disp.c|93|undefined reference to `glMatrixMode@4'| 33C:\Documents and Settings\Trent Gamblin\4.9.16\src\win\wgl_disp.c|94|undefined reference to `glLoadIdentity@0'| 34C:\Documents and Settings\Trent Gamblin\4.9.16\src\win\wgl_disp.c|95|undefined reference to `glOrtho@48'| 35C:\Documents and Settings\Trent Gamblin\4.9.16\src\win\wgl_disp.c|97|undefined reference to `glMatrixMode@4'| 36D:\Coding\allegro-4.9.16-mingw-bin\lib\liballegro-static-4.9.16.a(wgl_disp.c.obj)||In function `wgl_update_display_region':| 37C:\Documents and Settings\Trent Gamblin\4.9.16\src\win\wgl_disp.c|1299|undefined reference to `glFlush@0'| 38D:\Coding\allegro-4.9.16-mingw-bin\lib\liballegro-static-4.9.16.a(wgl_disp.c.obj)||In function `wgl_set_current_display':| 39C:\Documents and Settings\Trent Gamblin\4.9.16\src\win\wgl_disp.c|1112|undefined reference to `wglGetCurrentContext@0'| 40C:\Documents and Settings\Trent Gamblin\4.9.16\src\win\wgl_disp.c|1116|undefined reference to `wglMakeCurrent@8'| 41D:\Coding\allegro-4.9.16-mingw-bin\lib\liballegro-static-4.9.16.a(wgl_disp.c.obj)||In function `display_thread_proc':| 42C:\Documents and Settings\Trent Gamblin\4.9.16\src\win\wgl_disp.c|1258|undefined reference to `wglDeleteContext@4'| 43D:\Coding\allegro-4.9.16-mingw-bin\lib\liballegro-static-4.9.16.a(wgl_disp.c.obj)||In function `get_available_pixel_formats_ext':| 44C:\Documents and Settings\Trent Gamblin\4.9.16\src\win\wgl_disp.c|723|undefined reference to `wglGetCurrentContext@0'| 45C:\Documents and Settings\Trent Gamblin\4.9.16\src\win\wgl_disp.c|724|undefined reference to `wglGetCurrentDC@0'| 46D:\Coding\allegro-4.9.16-mingw-bin\lib\liballegro-static-4.9.16.a(wgl_disp.c.obj)||In function `init_pixel_format_extensions':| 47C:\Documents and Settings\Trent Gamblin\4.9.16\src\win\wgl_disp.c|178|undefined reference to `wglGetProcAddress@4'| 48C:\Documents and Settings\Trent Gamblin\4.9.16\src\win\wgl_disp.c|180|undefined reference to `wglGetProcAddress@4'| 49D:\Coding\allegro-4.9.16-mingw-bin\lib\liballegro-static-4.9.16.a(wgl_disp.c.obj)||In function `get_available_pixel_formats_ext':| 50C:\Documents and Settings\Trent Gamblin\4.9.16\src\win\wgl_disp.c|773|undefined reference to `wglMakeCurrent@8'| 51C:\Documents and Settings\Trent Gamblin\4.9.16\src\win\wgl_disp.c|775|undefined reference to `wglDeleteContext@4'| 52C:\Documents and Settings\Trent Gamblin\4.9.16\src\win\wgl_disp.c|778|undefined reference to `wglMakeCurrent@8'| 53C:\Documents and Settings\Trent Gamblin\4.9.16\src\win\wgl_disp.c|773|undefined reference to `wglMakeCurrent@8'| 54D:\Coding\allegro-4.9.16-mingw-bin\lib\liballegro-static-4.9.16.a(wgl_disp.c.obj)||In function `create_display_internals':| 55C:\Documents and Settings\Trent Gamblin\4.9.16\src\win\wgl_disp.c|949|undefined reference to `wglCreateContext@4'| 56C:\Documents and Settings\Trent Gamblin\4.9.16\src\win\wgl_disp.c|960|undefined reference to `wglMakeCurrent@8'| 57D:\Coding\allegro-4.9.16-mingw-bin\lib\liballegro-static-4.9.16.a(wgl_disp.c.obj)||In function `init_ogl_context_ex':| 58C:\Documents and Settings\Trent Gamblin\4.9.16\src\win\wgl_disp.c|661|undefined reference to `wglGetCurrentContext@0'| 59C:\Documents and Settings\Trent Gamblin\4.9.16\src\win\wgl_disp.c|662|undefined reference to `wglGetCurrentDC@0'| 60C:\Documents and Settings\Trent Gamblin\4.9.16\src\win\wgl_disp.c|683|undefined reference to `wglMakeCurrent@8'| 61C:\Documents and Settings\Trent Gamblin\4.9.16\src\win\wgl_disp.c|685|undefined reference to `wglDeleteContext@4'| 62C:\Documents and Settings\Trent Gamblin\4.9.16\src\win\wgl_disp.c|688|undefined reference to `wglMakeCurrent@8'| 63D:\Coding\allegro-4.9.16-mingw-bin\lib\liballegro-static-4.9.16.a(wgl_disp.c.obj)||In function `init_context_creation_extensions':| 64C:\Documents and Settings\Trent Gamblin\4.9.16\src\win\wgl_disp.c|197|undefined reference to `wglGetProcAddress@4'| 65D:\Coding\allegro-4.9.16-mingw-bin\lib\liballegro-static-4.9.16.a(wgl_disp.c.obj)||In function `init_ogl_context_ex':|

I'm not entirely sure what I'm doing wrong, or how I should resolve this. Can anybody help?

Trent Gamblin

You have to link some extra libraries. You'll need to link (this is for MSVC, change it to MinGW format like -llib): kernel32.lib user32.lib gdi32.lib comdlg32.lib ole32.lib winmm.lib psapi.lib opengl32.lib dxguid.lib dinput8.lib d3d9.lib allegro-static-4.9.16.lib plus any allegro-*-static-4.9.16 addon libraries you use.

NickWright

Thanks for the quick response =)

I've done what you suggested (I missed a few, should have noticed this before actually...), but I've still got a different set of errors.

Regarding changing the libraries' names to MinGW format, just to be clear, do you mean for example "gdi32.lib" becomes "libgdi32.a"?

#SelectExpand
1||=== test, Debug ===| 2||Warning: .drectve `/DEFAULTLIB:"uuid.lib" /DEFAULTLIB:"uuid.lib" ' unrecognized| 3||Warning: .drectve `/DEFAULTLIB:"uuid.lib" /DEFAULTLIB:"uuid.lib" ' unrecognized| 4D:\Coding\allegro-4.9.16-mingw-bin\lib\liballegro-static-4.9.16.a(d3d_disp.cpp.obj)||In function `d3d_generate_display_format_list':| 5C:\Documents and Settings\Trent Gamblin\4.9.16\src\win\d3d_disp.cpp|556|undefined reference to `_Unwind_Resume'| 6C:\Documents and Settings\Trent Gamblin\4.9.16\src\win\d3d_disp.cpp|555|undefined reference to `_Unwind_Resume'| 7D:\Coding\allegro-4.9.16-mingw-bin\lib\liballegro-static-4.9.16.a(d3d_disp.cpp.obj):d3d_disp.cpp:(.eh_frame+0x12)||undefined reference to `__gxx_personality_v0'| 8D:\Coding\allegro-4.9.16-mingw-bin\lib\liballegro-static-4.9.16.a(tls.c.obj)||In function `tls_get':| 9C:\Documents and Settings\Trent Gamblin\4.9.16\src\tls.c|240|undefined reference to `__emutls_get_address'| 10C:\Documents and Settings\Trent Gamblin\4.9.16\src\tls.c|241|undefined reference to `__emutls_get_address'| 11C:\Documents and Settings\Trent Gamblin\4.9.16\src\tls.c|241|undefined reference to `__emutls_get_address'| 12C:\Documents and Settings\Trent Gamblin\4.9.16\src\tls.c|242|undefined reference to `__emutls_get_address'| 13C:\Documents and Settings\Trent Gamblin\4.9.16\src\tls.c|242|undefined reference to `__emutls_get_address'| 14D:\Coding\allegro-4.9.16-mingw-bin\lib\liballegro-static-4.9.16.a(d3d_bmp.cpp.obj):d3d_bmp.cpp:(.eh_frame+0x11)||undefined reference to `__gxx_personality_v0'| 15||=== Build finished: 9 errors, 2 warnings ===|

Edit: oops

Trent Gamblin

You're either 1) using gcc < 4, which will not work with Allegro 5 static libs, or you're using a gcc that uses a different stack unwinding method than dwarf2, which will also not work. Since you're using code::blocks it's most likely "1" since it ships with gcc 3.4.5 IIRC. Upgrading your gcc to the latest stable MinGW version should work. Using "tdragon" builds of gcc may or may not work but is not supported by me :P.

NickWright

Ah. It's '1'. I'm not using the one bundled with Code::Blocks, I was using the one that's installed by default by the MinGW 5.1.6 'installer' package (the newest version) - but that's gcc 3.4.5 too.

I'll get a newer version of GCC and report back. Thanks very much for your help with this, I really appreciate it!

Edit:

Okay this was correct, it's working fine now. I might add this to the wiki. I have no idea why MinGW installs an old version of GCC, particularly because they have a newer version on their website to download.

Trent Gamblin

Yeah, they released a new version a few months (probably 6+ by now) and never updated the installer.

Thread #603070. Printed from Allegro.cc