Author Topic: Trying to cross-compile SDL2 dependant project with mingw32 in ubuntu  (Read 4300 times)

Iron Attorney

  • Guest
Hi there, I am new to the codeblocks forum! I have posted this on stack overflow a couple of days ago, and haven't recieved any responses, so I thought I would try my luck here aswell...

I have set up a mingw cross-compiler (i686-w64-mingw32) to compile a windows .exe on ubuntu with the Codeblocks IDE. My "hello world" test shows this to be working. I am now trying to cross-compile my full app which statically links to a number of SDL2 libraries. I am facing this list of errors:

Code
||=== Build: Windows in MyAppSDL (compiler: Windows X-Compile MinGW 32) ===|

windowsLibs/SDL2x86/lib/libSDL2.a(SDL_systimer.o)||In function `timeSetPeriod':|
/Users/slouken/release/SDL/SDL2-2.0.3-source/foo-x86/../src/timer/windows/SDL_systimer.c|58|undefined reference to `_imp__timeBeginPeriod@4'|
/Users/slouken/release/SDL/SDL2-2.0.3-source/foo-x86/../src/timer/windows/SDL_systimer.c|52|undefined reference to `_imp__timeEndPeriod@4'|
/Users/slouken/release/SDL/SDL2-2.0.3-source/foo-x86/../src/timer/windows/SDL_systimer.c|58|undefined reference to `_imp__timeBeginPeriod@4'|
windowsLibs/SDL2x86/lib/libSDL2.a(SDL_systimer.o)||In function `SDL_TicksInit':|
/Users/slouken/release/SDL/SDL2-2.0.3-source/foo-x86/../src/timer/windows/SDL_systimer.c|106|undefined reference to `_imp__timeGetTime@0'|
windowsLibs/SDL2x86/lib/libSDL2.a(SDL_systimer.o)||In function `timeSetPeriod':|
/Users/slouken/release/SDL/SDL2-2.0.3-source/foo-x86/../src/timer/windows/SDL_systimer.c|52|undefined reference to `_imp__timeEndPeriod@4'|
/Users/slouken/release/SDL/SDL2-2.0.3-source/foo-x86/../src/timer/windows/SDL_systimer.c|52|undefined reference to `_imp__timeEndPeriod@4'|
windowsLibs/SDL2x86/lib/libSDL2.a(SDL_systimer.o)||In function `SDL_GetTicks_REAL':|
/Users/slouken/release/SDL/SDL2-2.0.3-source/foo-x86/../src/timer/windows/SDL_systimer.c|159|undefined reference to `_imp__timeGetTime@0'|
windowsLibs/SDL2x86/lib/libSDL2.a(SDL_systimer.o)||In function `timeSetPeriod':|
/Users/slouken/release/SDL/SDL2-2.0.3-source/foo-x86/../src/timer/windows/SDL_systimer.c|58|undefined reference to `_imp__timeBeginPeriod@4'|
windowsLibs/SDL2x86/lib/libSDL2.a(SDL_systimer.o)||In function `SDL_TicksInit':|
/Users/slouken/release/SDL/SDL2-2.0.3-source/foo-x86/../src/timer/windows/SDL_systimer.c|106|undefined reference to `_imp__timeGetTime@0'|
windowsLibs/SDL2x86/lib/libSDL2.a(SDL_systimer.o)||In function `timeSetPeriod':|
/Users/slouken/release/SDL/SDL2-2.0.3-source/foo-x86/../src/timer/windows/SDL_systimer.c|52|undefined reference to `_imp__timeEndPeriod@4'|
windowsLibs/SDL2x86/lib/libSDL2.a(SDL_systimer.o)||In function `SDL_GetTicks_REAL':|
/Users/slouken/release/SDL/SDL2-2.0.3-source/foo-x86/../src/timer/windows/SDL_systimer.c|159|undefined reference to `_imp__timeGetTime@0'|
windowsLibs/SDL2x86/lib/libSDL2.a(SDL_systimer.o)||In function `timeSetPeriod':|
/Users/slouken/release/SDL/SDL2-2.0.3-source/foo-x86/../src/timer/windows/SDL_systimer.c|58|undefined reference to `_imp__timeBeginPeriod@4'|
windowsLibs/SDL2x86/lib/libSDL2.a(SDL_systimer.o)||In function `SDL_TicksInit':|
/Users/slouken/release/SDL/SDL2-2.0.3-source/foo-x86/../src/timer/windows/SDL_systimer.c|106|undefined reference to `_imp__timeGetTime@0'|
windowsLibs/SDL2x86/lib/libSDL2.a(SDL_systimer.o)||In function `timeSetPeriod':|
/Users/slouken/release/SDL/SDL2-2.0.3-source/foo-x86/../src/timer/windows/SDL_systimer.c|52|undefined reference to `_imp__timeEndPeriod@4'|
windowsLibs/SDL2x86/lib/libSDL2.a(SDL_windows.o)||In function `WIN_CoInitialize':|
/Users/slouken/release/SDL/SDL2-2.0.3-source/foo-x86/../src/core/windows/SDL_windows.c|68|undefined reference to `_imp__CoInitializeEx@8'|
windowsLibs/SDL2x86/lib/libSDL2.a(SDL_windows.o)||In function `WIN_CoUninitialize':|
/Users/slouken/release/SDL/SDL2-2.0.3-source/foo-x86/../src/core/windows/SDL_windows.c|87|undefined reference to `_imp__CoUninitialize@0'|
windowsLibs/SDL2x86/lib/libSDL2.a(SDL_windowsmouse.o)||In function `WIN_CreateCursor':|
/Users/slouken/release/SDL/SDL2-2.0.3-source/foo-x86/../src/video/windows/SDL_windowsmouse.c|91|undefined reference to `_imp__CreateDIBSection@24'|
/Users/slouken/release/SDL/SDL2-2.0.3-source/foo-x86/../src/video/windows/SDL_windowsmouse.c|92|undefined reference to `_imp__CreateBitmap@20'|
/Users/slouken/release/SDL/SDL2-2.0.3-source/foo-x86/../src/video/windows/SDL_windowsmouse.c|102|undefined reference to `_imp__DeleteObject@4'|
windowsLibs/SDL2x86/lib/libSDL2.a(SDL_windowskeyboard.o)||In function `IME_SetupAPI':|
/Users/slouken/release/SDL/SDL2-2.0.3-source/foo-x86/../src/video/windows/SDL_windowskeyboard.c|596|undefined reference to `ImmGetIMEFileNameA@12'|
/Users/slouken/release/SDL/SDL2-2.0.3-source/foo-x86/../src/video/windows/SDL_windowskeyboard.c|609|undefined reference to `ImmGetContext@4'|
/Users/slouken/release/SDL/SDL2-2.0.3-source/foo-x86/../src/video/windows/SDL_windowskeyboard.c|612|undefined reference to `ImmReleaseContext@8'|
windowsLibs/SDL2x86/lib/libSDL2.a(SDL_windowskeyboard.o)||In function `IME_GetId':|
/Users/slouken/release/SDL/SDL2-2.0.3-source/foo-x86/../src/video/windows/SDL_windowskeyboard.c|530|undefined reference to `ImmGetIMEFileNameA@12'|
/Users/slouken/release/SDL/SDL2-2.0.3-source/foo-x86/../src/video/windows/SDL_windowskeyboard.c|545|undefined reference to `GetFileVersionInfoSizeA@8'|
/Users/slouken/release/SDL/SDL2-2.0.3-source/foo-x86/../src/video/windows/SDL_windowskeyboard.c|549|undefined reference to `GetFileVersionInfoA@16'|
/Users/slouken/release/SDL/SDL2-2.0.3-source/foo-x86/../src/video/windows/SDL_windowskeyboard.c|550|undefined reference to `VerQueryValueA@16'|
windowsLibs/SDL2x86/lib/libSDL2.a(SDL_windowskeyboard.o)||In function `UILess_GetCandidateList':|
/Users/slouken/release/SDL/SDL2-2.0.3-source/foo-x86/../src/video/windows/SDL_windowskeyboard.c|966|undefined reference to `_imp__SysFreeString@4'|
windowsLibs/SDL2x86/lib/libSDL2.a(SDL_windowskeyboard.o)||In function `IME_ClearComposition':|
/Users/slouken/release/SDL/SDL2-2.0.3-source/foo-x86/../src/video/windows/SDL_windowskeyboard.c|662|undefined reference to `ImmGetContext@4'|
/Users/slouken/release/SDL/SDL2-2.0.3-source/foo-x86/../src/video/windows/SDL_windowskeyboard.c|666|undefined reference to `ImmNotifyIME@16'|
/Users/slouken/release/SDL/SDL2-2.0.3-source/foo-x86/../src/video/windows/SDL_windowskeyboard.c|670|undefined reference to `ImmNotifyIME@16'|
/Users/slouken/release/SDL/SDL2-2.0.3-source/foo-x86/../src/video/windows/SDL_windowskeyboard.c|671|undefined reference to `ImmReleaseContext@8'|
windowsLibs/SDL2x86/lib/libSDL2.a(SDL_windowskeyboard.o)||In function `IME_Disable':|
/Users/slouken/release/SDL/SDL2-2.0.3-source/foo-x86/../src/video/windows/SDL_windowskeyboard.c|344|undefined reference to `ImmAssociateContext@8'|
windowsLibs/SDL2x86/lib/libSDL2.a(SDL_windowskeyboard.o)||In function `IME_ClearComposition':|
/Users/slouken/release/SDL/SDL2-2.0.3-source/foo-x86/../src/video/windows/SDL_windowskeyboard.c|668|undefined reference to `ImmSetCompositionStringW@24'|
/Users/slouken/release/SDL/SDL2-2.0.3-source/foo-x86/../src/video/windows/SDL_windowskeyboard.c|662|undefined reference to `ImmGetContext@4'|
/Users/slouken/release/SDL/SDL2-2.0.3-source/foo-x86/../src/video/windows/SDL_windowskeyboard.c|666|undefined reference to `ImmNotifyIME@16'|
/Users/slouken/release/SDL/SDL2-2.0.3-source/foo-x86/../src/video/windows/SDL_windowskeyboard.c|670|undefined reference to `ImmNotifyIME@16'|
/Users/slouken/release/SDL/SDL2-2.0.3-source/foo-x86/../src/video/windows/SDL_windowskeyboard.c|671|undefined reference to `ImmReleaseContext@8'|
/Users/slouken/release/SDL/SDL2-2.0.3-source/foo-x86/../src/video/windows/SDL_windowskeyboard.c|668|undefined reference to `ImmSetCompositionStringW@24'|
windowsLibs/SDL2x86/lib/libSDL2.a(SDL_windowskeyboard.o)||In function `UIElementSink_BeginUIElement@12':|
/Users/slouken/release/SDL/SDL2-2.0.3-source/foo-x86/../src/video/windows/SDL_windowskeyboard.c|1033|undefined reference to `_imp__SysFreeString@4'|
windowsLibs/SDL2x86/lib/libSDL2.a(SDL_windowskeyboard.o)||In function `UIElementSink_UpdateUIElement@8':|
/Users/slouken/release/SDL/SDL2-2.0.3-source/foo-x86/../src/video/windows/SDL_windowskeyboard.c|1060|undefined reference to `_imp__SysFreeString@4'|
windowsLibs/SDL2x86/lib/libSDL2.a(SDL_windowskeyboard.o)||In function `IME_Init':|
/Users/slouken/release/SDL/SDL2-2.0.3-source/foo-x86/../src/video/windows/SDL_windowskeyboard.c|289|undefined reference to `_imp__CoCreateInstance@20'|
/Users/slouken/release/SDL/SDL2-2.0.3-source/foo-x86/../src/video/windows/SDL_windowskeyboard.c|303|undefined reference to `ImmGetContext@4'|
/Users/slouken/release/SDL/SDL2-2.0.3-source/foo-x86/../src/video/windows/SDL_windowskeyboard.c|304|undefined reference to `ImmReleaseContext@8'|
windowsLibs/SDL2x86/lib/libSDL2.a(SDL_windowskeyboard.o)||In function `UILess_SetupSinks':|
/Users/slouken/release/SDL/SDL2-2.0.3-source/foo-x86/../src/video/windows/SDL_windowskeyboard.c|1174|undefined reference to `_imp__CoCreateInstance@20'|
windowsLibs/SDL2x86/lib/libSDL2.a(SDL_windowskeyboard.o)||In function `IME_GetId':|
/Users/slouken/release/SDL/SDL2-2.0.3-source/foo-x86/../src/video/windows/SDL_windowskeyboard.c|530|undefined reference to `ImmGetIMEFileNameA@12'|
/Users/slouken/release/SDL/SDL2-2.0.3-source/foo-x86/../src/video/windows/SDL_windowskeyboard.c|545|undefined reference to `GetFileVersionInfoSizeA@8'|
/Users/slouken/release/SDL/SDL2-2.0.3-source/foo-x86/../src/video/windows/SDL_windowskeyboard.c|549|undefined reference to `GetFileVersionInfoA@16'|
windowsLibs/SDL2x86/lib/libSDL2.a(SDL_windowskeyboard.o)||In function `IME_GetReadingString':|
/Users/slouken/release/SDL/SDL2-2.0.3-source/foo-x86/../src/video/windows/SDL_windowskeyboard.c|402|undefined reference to `ImmGetContext@4'|
/Users/slouken/release/SDL/SDL2-2.0.3-source/foo-x86/../src/video/windows/SDL_windowskeyboard.c|477|undefined reference to `ImmReleaseContext@8'|
windowsLibs/SDL2x86/lib/libSDL2.a(SDL_windowskeyboard.o)||In function `IME_GetId':|
/Users/slouken/release/SDL/SDL2-2.0.3-source/foo-x86/../src/video/windows/SDL_windowskeyboard.c|550|undefined reference to `VerQueryValueA@16'|
||More errors follow but not being shown.|
||Edit the max errors limit in compiler options...|
||=== Build failed: 50 error(s), 0 warning(s) (0 minute(s), 10 second(s)) ===|

I have done a bit of research, and from what I gather, it is because SDL2 wants to dynamically link to some of the windows system libraries. I have also gathered that either mingw or SDL2 comes with the resources to resolve these issues, but I can't figure out what or where these are. While some resources seem to solve the issue, I can never totally follow what the solution actually was. Here are a small selection of the resources I have found on stackoverflow that I think are relevant:

http://stackoverflow.com/questions/28260245/receiving-undefined-references-to-various-windows-libraries-when-compiling-with
http://stackoverflow.com/questions/19396669/wxwidgets-how-to-cross-compile-an-application-for-windows-from-linux-using-codeb
http://stackoverflow.com/questions/30157718/linking-libcurl-while-cross-compiling-with-mingw32-under-linux-for-windows

The first link lists the .dlls that SDL2 wants to link to. The solution didn't however mention how to link to them. I have found all these libraries on my windows machine, and I did naively attempt to put them in my project folder and dynamically link them, but ubuntu doesn't recognise the .dlls.

The second link is regarding cross-compiling a wxWidgets app for windows, from ubuntu, using Codeblocks IDE. A particular couple of lines from the solution interest me. They regard setting up the compiler.

Code
Compiler Settings >  Other Options : `/usr/local/i586-mingw32/bin/wx-config --cxxflags` 
Linker Settings > Other Options : `/usr/local/i586-mingw32/bin/wx-config --libs`

This is the only part of the solution's compiler setup that differ from my own compiler setup. I have nothing in either of these "Other Options" sections. Obviously the particular filepaths/filenames relate to wxWidgets specifically, but I was wondering if I would need to find some similar files for my SDL2 libraries? I have had a scout around the file system, and no luck.

The third link discusses linking to a .dll, by cross-compiling it in mingw first. I don't understand all the instructions there, maybe because I've had my life sugarcoated with IDE's and have never dealt with the nitty-gritty of compiling a program, regardless, I am fairly certain this resource is relevant.

Any help will be much appreciated!

Pete.