在使用SDL 2和-static进行编译时,接收对各种Windows库的未定义引用?

时间:2015-02-01 06:46:46

标签: c++ sdl sdl-2

我正在修改SDL2中的Wolfenstein 3D引擎(使用Wolf4SDL作为基础)并且我遇到了一个问题 - 当在链接器选项中使用-static时,我得到一个大的对各种事物的各种未定义的引用。这是我的构建日志,以显示我的意思:

-------------- Build: Debug in Lazarus (compiler: GNU GCC Compiler)---------------
i686-w64-mingw32-g++.exe -LC:\SDL2\lib -o Lazarus.exe .objs\alu_cache.o .objs\alu_dbg_mem.o .objs\alu_gfx.o .objs\alu_hud.o .objs\alu_in.o .objs\alu_me_core.o .objs\alu_me_gui.o .objs\alu_me_symbols.o .objs\alu_me_textinput.o .objs\alu_me_tools.o .objs\alu_me_windows.o .objs\alu_menu.o .objs\alu_pak.o .objs\alu_particles.o .objs\asmcomp.o .objs\id_us_1.o .objs\vieasm.o .objs\wl_act1.o .objs\wl_act2.o .objs\wl_agent.o .objs\wl_debug.o .objs\wl_dir3dspr.o .objs\wl_draw.o .objs\wl_floorceiling.o .objs\wl_game.o .objs\wl_inter.o .objs\wl_main.o .objs\wl_play.o .objs\wl_state.o .objs\wl_text.o  -static -pg -lgmon  -lmingw32 -lSDL2main -lSDL2 -lSDL2_image -lSDL2_mixer -mwindows 
C:\SDL2\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' 
C:\SDL2\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' 
C:\SDL2\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' 
C:\SDL2\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' 
C:\SDL2\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' 
C:\SDL2\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' 
C:\SDL2\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' 
C:\SDL2\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' 
C:\SDL2\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' 
C:\SDL2\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' 
C:\SDL2\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' 
C:\SDL2\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' 
C:\SDL2\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' 
C:\SDL2\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' 
C:\SDL2\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' 
C:\SDL2\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' 
C:\SDL2\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' 
C:\SDL2\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' 
C:\SDL2\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' 
C:\SDL2\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' 
C:\SDL2\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' 
C:\SDL2\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' 
C:\SDL2\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' 
C:\SDL2\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' 
C:\SDL2\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' 
C:\SDL2\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' 
C:\SDL2\lib\libSDL2.a(SDL_windowskeyboard.o): In function `IME_Quit': 
/Users/slouken/release/SDL/SDL2-2.0.3-source/foo-x86/../src/video/windows/SDL_windowskeyboard.c:358: undefined reference to `ImmAssociateContext@8' 
C:\SDL2\lib\libSDL2.a(SDL_windowskeyboard.o): In function `IME_Enable': 
/Users/slouken/release/SDL/SDL2-2.0.3-source/foo-x86/../src/video/windows/SDL_windowskeyboard.c:329: undefined reference to `ImmAssociateContext@8' 
C:\SDL2\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' 
Process terminated with status 1 (0 minute(s), 0 second(s)) 
50 error(s), 0 warning(s) (0 minute(s), 0 second(s))

当链接普通的Wolf4SDL mod(使用SDL 1.2)时,这种情况不会发生,如果我不使用-static,它会正确链接,但在没有其他各种DLL存在的情况下运行(即libgcc_s_dw2-1.dll等)。虽然我可以更改PATH以包含我的MinGW目录,但是当分发它时,我不能指望每个人都安装了MinGW,并且我想保留我用我的mod分发的DLL的数量。至少考虑到我已经使用了SDL_mixer和SDL_image,它已经有大量的DLL了。任何人都有解决方案吗?

2 个答案:

答案 0 :(得分:5)

好的,修复了问题 - 我需要链接各种Windows库,即Ole32,Oleaut32,Imm32,Winmm和Version。不确定为什么SDL 1的情况并非如此;迁移指南中没有提到它,所以我不确定差异来自何处。

答案 1 :(得分:0)

对我而言,这意味着"使用pkg-config --static"因为我编译了一个静态版本,并希望使用它。

猜猜pkg-config是如何滚动的。 另一种选择(如提到的OP)是要么添加你需要的库和#34;带外"或修改sdl2.pc,使其包含"您需要的所有库"在Libs:line(不是Libs.static:可能已经拥有它们的行)。

再次,pkg-config如何滚动:|