0

我已經設置了一個mingw交叉編譯器(i686-w64-mingw32)來在ubuntu上用Codeblocks IDE編譯一個windows .exe。我的「你好世界」測試顯示這個工作。我現在正在嘗試交叉編譯我的完整應用程序,它可以靜態鏈接到許多SDL2庫。我面對錯誤此列表:如何在交叉編譯時鏈接到來自Ubuntu的Windows系統.dll? (使用代碼塊)

||=== 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 `[email protected]'| 
/Users/slouken/release/SDL/SDL2-2.0.3-source/foo-x86/../src/timer/windows/SDL_systimer.c|52|undefined reference to `[email protected]'| 
/Users/slouken/release/SDL/SDL2-2.0.3-source/foo-x86/../src/timer/windows/SDL_systimer.c|58|undefined reference to `[email protected]'| 
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 `[email protected]'| 
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 `[email protected]'| 
/Users/slouken/release/SDL/SDL2-2.0.3-source/foo-x86/../src/timer/windows/SDL_systimer.c|52|undefined reference to `[email protected]'| 
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 `[email protected]'| 
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 `[email protected]'| 
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 `[email protected]'| 
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 `[email protected]'| 
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 `[email protected]'| 
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 `[email protected]'| 
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 `[email protected]'| 
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 `[email protected]'| 
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 `[email protected]'| 
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 `[email protected]'| 
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 `[email protected]'| 
/Users/slouken/release/SDL/SDL2-2.0.3-source/foo-x86/../src/video/windows/SDL_windowsmouse.c|92|undefined reference to `[email protected]'| 
/Users/slouken/release/SDL/SDL2-2.0.3-source/foo-x86/../src/video/windows/SDL_windowsmouse.c|102|undefined reference to `[email protected]'| 
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 `[email protected]'| 
/Users/slouken/release/SDL/SDL2-2.0.3-source/foo-x86/../src/video/windows/SDL_windowskeyboard.c|609|undefined reference to `[email protected]'| 
/Users/slouken/release/SDL/SDL2-2.0.3-source/foo-x86/../src/video/windows/SDL_windowskeyboard.c|612|undefined reference to `[email protected]'| 
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 `[email protected]'| 
/Users/slouken/release/SDL/SDL2-2.0.3-source/foo-x86/../src/video/windows/SDL_windowskeyboard.c|545|undefined reference to `[email protected]'| 
/Users/slouken/release/SDL/SDL2-2.0.3-source/foo-x86/../src/video/windows/SDL_windowskeyboard.c|549|undefined reference to `[email protected]'| 
/Users/slouken/release/SDL/SDL2-2.0.3-source/foo-x86/../src/video/windows/SDL_windowskeyboard.c|550|undefined reference to `[email protected]'| 
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 `[email protected]'| 
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 `[email protected]'| 
/Users/slouken/release/SDL/SDL2-2.0.3-source/foo-x86/../src/video/windows/SDL_windowskeyboard.c|666|undefined reference to `[email protected]'| 
/Users/slouken/release/SDL/SDL2-2.0.3-source/foo-x86/../src/video/windows/SDL_windowskeyboard.c|670|undefined reference to `[email protected]'| 
/Users/slouken/release/SDL/SDL2-2.0.3-source/foo-x86/../src/video/windows/SDL_windowskeyboard.c|671|undefined reference to `[email protected]'| 
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 `[email protected]'| 
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 `[email protected]'| 
/Users/slouken/release/SDL/SDL2-2.0.3-source/foo-x86/../src/video/windows/SDL_windowskeyboard.c|662|undefined reference to `[email protected]'| 
/Users/slouken/release/SDL/SDL2-2.0.3-source/foo-x86/../src/video/windows/SDL_windowskeyboard.c|666|undefined reference to `[email protected]'| 
/Users/slouken/release/SDL/SDL2-2.0.3-source/foo-x86/../src/video/windows/SDL_windowskeyboard.c|670|undefined reference to `[email protected]'| 
/Users/slouken/release/SDL/SDL2-2.0.3-source/foo-x86/../src/video/windows/SDL_windowskeyboard.c|671|undefined reference to `[email protected]'| 
/Users/slouken/release/SDL/SDL2-2.0.3-source/foo-x86/../src/video/windows/SDL_windowskeyboard.c|668|undefined reference to `[email protected]'| 
windowsLibs/SDL2x86/lib/libSDL2.a(SDL_windowskeyboard.o)||In function `[email protected]':| 
/Users/slouken/release/SDL/SDL2-2.0.3-source/foo-x86/../src/video/windows/SDL_windowskeyboard.c|1033|undefined reference to `[email protected]'| 
windowsLibs/SDL2x86/lib/libSDL2.a(SDL_windowskeyboard.o)||In function `[email protected]':| 
/Users/slouken/release/SDL/SDL2-2.0.3-source/foo-x86/../src/video/windows/SDL_windowskeyboard.c|1060|undefined reference to `[email protected]'| 
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__Co[email protected]'| 
/Users/slouken/release/SDL/SDL2-2.0.3-source/foo-x86/../src/video/windows/SDL_windowskeyboard.c|303|undefined reference to `[email protected]'| 
/Users/slouken/release/SDL/SDL2-2.0.3-source/foo-x86/../src/video/windows/SDL_windowskeyboard.c|304|undefined reference to `[email protected]'| 
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 `[email protected]'| 
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 `[email protected]'| 
/Users/slouken/release/SDL/SDL2-2.0.3-source/foo-x86/../src/video/windows/SDL_windowskeyboard.c|545|undefined reference to `[email protected]'| 
/Users/slouken/release/SDL/SDL2-2.0.3-source/foo-x86/../src/video/windows/SDL_windowskeyboard.c|549|undefined reference to `[email protected]'| 
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 `[email protected]'| 
/Users/slouken/release/SDL/SDL2-2.0.3-source/foo-x86/../src/video/windows/SDL_windowskeyboard.c|477|undefined reference to `[email protected]'| 
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 `[email protected]'| 
||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系統庫。我也認識到,無論是明或SDL2都有資源來解決這些問題,但我無法弄清楚這些是什麼或在哪裏。雖然有些資源似乎解決了這個問題,但我永遠無法完全遵循實際的解決方案。以下是我已經在計算器中發現的資源,我認爲的一小部分是相關的:

Receiving undefined references to various Windows libraries when compiling with SDL 2 and -static? wxWidgets how to cross compile an application for windows from linux using codeblocks? Linking libcurl while cross compiling with mingw32 under Linux for Windows

第一個鏈接列出了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庫找到一些類似的文件?我在文件系統周圍有一名偵察員,但沒有運氣。

第三個鏈接首先討論鏈接到.dll,通過在mingw中交叉編譯。我不明白那裏的所有說明,也許是因爲我已經用IDE編寫了糖衣,從未處理過編譯程序的細節問題,無論我相當肯定這個資源是相關的。

任何幫助將不勝感激!

皮特。

回答

0

好的,所以我今天設法從Ubuntu交叉編譯我的SDL2依賴於Windows的應用程序。

我的第一個錯誤是嘗試靜態鏈接到SDL2 Windows庫(.lib)。我需要做的是鏈接到.dll.a文件進行編譯。這些都是在mingw文件夾中隨SDL2提供的。這些文件夾是:

的i686-W64-mingw32的爲32個庫 x86_64的-W64-mingw32的爲64個庫

然後我遇到我真正得到它的工作之前,其他一些錯誤。我列出瞭解決這些問題的步驟,以解答另一篇文章的答案:

SDL doesn't compile in native enviroment

相關問題