交叉编译时如何从ubuntu链接到windows system.dll?(使用代码块)

交叉编译时如何从ubuntu链接到windows system.dll?(使用代码块),windows,shared-libraries,ubuntu-14.04,codeblocks,cross-compiling,Windows,Shared Libraries,Ubuntu 14.04,Codeblocks,Cross Compiling,我已经设置了一个mingw交叉编译器(i686-w64-mingw32),在ubuntu上用代码块IDE编译windows.exe。我的“hello world”测试表明这是可行的。我现在正试图交叉编译我的完整应用程序,它静态链接到许多SDL2库。我面临以下错误列表: ||=== Build: Windows in MyAppSDL (compiler: Windows X-Compile MinGW 32) ===| windowsLibs/SDL2x86/lib/libSDL2.a(SDL

我已经设置了一个mingw交叉编译器(i686-w64-mingw32),在ubuntu上用代码块IDE编译windows.exe。我的“hello world”测试表明这是可行的。我现在正试图交叉编译我的完整应用程序,它静态链接到许多SDL2库。我面临以下错误列表:

||=== 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)) ===|
我做了一些研究,据我所知,这是因为SDL2希望动态链接到一些windows系统库。我还收集到,mingw或SDL2都提供了解决这些问题的资源,但我不知道它们是什么或在哪里。虽然有些资源似乎可以解决这个问题,但我永远无法完全理解解决方案的实际内容。以下是我在stackoverflow上找到的一些我认为相关的资源:

第一个链接列出SDL2要链接到的.dll。然而,解决方案没有提到如何链接到它们。我在我的windows机器上找到了所有这些库,我天真地尝试将它们放在我的项目文件夹中并动态链接它们,但ubuntu无法识别.dll

第二个链接是关于使用Codeblocks IDE从ubuntu交叉编译用于windows的wxWidgets应用程序。我对解决方案中的几行特别感兴趣。他们考虑设置编译器

Compiler Settings >  Other Options : `/usr/local/i586-mingw32/bin/wx-config --cxxflags` 
Linker Settings > Other Options : `/usr/local/i586-mingw32/bin/wx-config --libs`
这是解决方案编译器设置中唯一与我自己的编译器设置不同的部分。我在这两个“其他选项”部分都没有。显然,特定的文件路径/文件名与wxWidgets相关,但我想知道是否需要为我的SDL2库找到一些类似的文件?我在文件系统里找了一个侦探,但运气不好

第三个链接讨论如何通过在mingw first中交叉编译来链接到.dll。我不理解那里的所有说明,可能是因为我的生活中有过IDE的糖衣,从来没有处理过编译程序的细节,不管怎样,我相当肯定这个资源是相关的

任何帮助都将不胜感激


皮特。

好的,所以我今天设法从Ubuntu交叉编译了我的依赖SDL2的Windows应用程序

我的第一个错误是尝试静态链接到SDL2 windows库(.lib)。我需要做的是链接到.dll.a文件进行编译。这些都是在mingw文件夹中随SDL2提供的。这些文件夹是:

32位库的i686-w64-mingw32 用于64位库的x86_64-w64-mingw32

在我真正让它工作之前,我还面临着其他一些错误。我在另一篇帖子的回复中列出了解决这些问题的步骤: