是否收到对各种Windows库的未定义引用

是否收到对各种Windows库的未定义引用

本文介绍了使用SDL 2和-static进行编译时,是否收到对各种Windows库的未定义引用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I'm working on a modification of the Wolfenstein 3D engine in SDL2 (using Wolf4SDL as a base) and I've run into a problem - when using -static in the linker options, I get a large variety of undefined references to various things. Here's my build log to show what I mean:

-------------- 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的数量保持在最低限度,我已经在使用带有大量DLL的SDL_mixer和SDL_image了.有人对此有解决方案吗?

This does not happen when linking a normal Wolf4SDL mod (which uses SDL 1.2), and it links correctly if I don't use -static but then won't run without various other DLLs being present (namely libgcc_s_dw2-1.dll and the like). While I can just change PATH to include my MinGW directory, when it comes time to distribute it I can't expect everyone to have MinGW installed, and I want to keep the number of DLLs I'm distributing with my mod to a minimum considering I'm already using SDL_mixer and SDL_image which come with a ton of DLLs already. Anyone have a solution to this?

推荐答案

好,解决了这个问题-我需要链接各种Windows库,即Ole32,Oleaut32,Imm32,Winmm和Version.不确定SDL 1为何不是这种情况.迁移指南中也没有提到它,所以我不确定差异的来源.

OK, fixed the problem - I needed to link a variety of Windows libraries, namely Ole32, Oleaut32, Imm32, Winmm and Version. Not sure why this wasn't the case for SDL 1; it wasn't mentioned in the Migration Guide either so I'm not sure where the difference comes from.

这篇关于使用SDL 2和-static进行编译时,是否收到对各种Windows库的未定义引用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-23 08:52