How to fix libSDL.a(xyz): undefined reference to `__imp_timeBeginPeriod' and friends
How to fix this error :
/usr/local/cross-tools/x86_64-w64-mingw32/lib/libSDL.a(SDL_systimer.o):SDL_systimer.c:(.text+0x25): undefined reference to `__imp_timeBeginPeriod' /usr/local/cross-tools/x86_64-w64-mingw32/lib/libSDL.a(SDL_systimer.o):SDL_systimer.c:(.text+0x2b): undefined reference to `__imp_timeGetTime' /usr/local/cross-tools/x86_64-w64-mingw32/lib/libSDL.a(SDL_systimer.o):SDL_systimer.c:(.text+0x50): undefined reference to `__imp_timeGetTime' /usr/local/cross-tools/x86_64-w64-mingw32/lib/libSDL.a(SDL_systimer.o):SDL_systimer.c:(.text+0xbb): undefined reference to `__imp_timeBeginPeriod' /usr/local/cross-tools/x86_64-w64-mingw32/lib/libSDL.a(SDL_systimer.o):SDL_systimer.c:(.text+0xe1): undefined reference to `__imp_timeSetEvent' /usr/local/cross-tools/x86_64-w64-mingw32/lib/libSDL.a(SDL_systimer.o):SDL_systimer.c:(.text+0x140): undefined reference to `__imp_timeKillEvent' /usr/local/cross-tools/x86_64-w64-mingw32/lib/libSDL.a(SDL_systimer.o):SDL_systimer.c:(.text+0x147): undefined reference to `__imp_timeEndPeriod' /usr/local/cross-tools/x86_64-w64-mingw32/lib/libSDL.a(SDL_dx5video.o):SDL_dx5video.c:(.text+0x150f): undefined reference to `IID_IDirectDrawGammaControl' /usr/local/cross-tools/x86_64-w64-mingw32/lib/libSDL.a(SDL_dx5video.o):SDL_dx5video.c:(.text+0x187f): undefined reference to `IID_IDirectDrawGammaControl' /usr/local/cross-tools/x86_64-w64-mingw32/lib/libSDL.a(SDL_dx5video.o):SDL_dx5video.c:(.data+0xa0): undefined reference to `GUID_XAxis' /usr/local/cross-tools/x86_64-w64-mingw32/lib/libSDL.a(SDL_dx5video.o):SDL_dx5video.c:(.data+0xb8): undefined reference to `GUID_YAxis' /usr/local/cross-tools/x86_64-w64-mingw32/lib/libSDL.a(SDL_dx5video.o):SDL_dx5video.c:(.data+0xd0): undefined reference to `GUID_ZAxis' /usr/local/cross-tools/x86_64-w64-mingw32/lib/libSDL.a(SDL_dx5video.o):SDL_dx5video.c:(.data+0xe8): undefined reference to `GUID_RxAxis' /usr/local/cross-tools/x86_64-w64-mingw32/lib/libSDL.a(SDL_dx5video.o):SDL_dx5video.c:(.data+0x100): undefined reference to `GUID_RyAxis' /usr/local/cross-tools/x86_64-w64-mingw32/lib/libSDL.a(SDL_dx5video.o):SDL_dx5video.c:(.data+0x118): undefined reference to `GUID_RzAxis' /usr/local/cross-tools/x86_64-w64-mingw32/lib/libSDL.a(SDL_dx5video.o):SDL_dx5video.c:(.data+0x130): undefined reference to `GUID_Slider' /usr/local/cross-tools/x86_64-w64-mingw32/lib/libSDL.a(SDL_dx5video.o):SDL_dx5video.c:(.data+0x148): undefined reference to `GUID_Slider' /usr/local/cross-tools/x86_64-w64-mingw32/lib/libSDL.a(SDL_dx5video.o):SDL_dx5video.c:(.data+0x160): undefined reference to `GUID_POV' /usr/local/cross-tools/x86_64-w64-mingw32/lib/libSDL.a(SDL_dx5video.o):SDL_dx5video.c:(.data+0x178): undefined reference to `GUID_POV' /usr/local/cross-tools/x86_64-w64-mingw32/lib/libSDL.a(SDL_dx5video.o):SDL_dx5video.c:(.data+0x190): undefined reference to `GUID_POV' /usr/local/cross-tools/x86_64-w64-mingw32/lib/libSDL.a(SDL_dx5video.o):SDL_dx5video.c:(.data+0x1a8): undefined reference to `GUID_POV' /usr/local/cross-tools/x86_64-w64-mingw32/lib/libSDL.a(SDL_dx5video.o):SDL_dx5video.c:(.data+0x4c0): undefined reference to `GUID_XAxis' /usr/local/cross-tools/x86_64-w64-mingw32/lib/libSDL.a(SDL_dx5video.o):SDL_dx5video.c:(.data+0x4d8): undefined reference to `GUID_YAxis' /usr/local/cross-tools/x86_64-w64-mingw32/lib/libSDL.a(SDL_dx5video.o):SDL_dx5video.c:(.data+0x4f0): undefined reference to `GUID_ZAxis' /usr/local/cross-tools/x86_64-w64-mingw32/lib/libSDL.a(SDL_dx5video.o):SDL_dx5video.c:(.data+0x5e0): undefined reference to `GUID_XAxis' /usr/local/cross-tools/x86_64-w64-mingw32/lib/libSDL.a(SDL_dx5video.o):SDL_dx5video.c:(.data+0x5f8): undefined reference to `GUID_YAxis' /usr/local/cross-tools/x86_64-w64-mingw32/lib/libSDL.a(SDL_dx5video.o):SDL_dx5video.c:(.data+0x610): undefined reference to `GUID_ZAxis' /usr/local/cross-tools/x86_64-w64-mingw32/lib/libSDL.a(SDL_dx5video.o):SDL_dx5video.c:(.data+0x6a0): undefined reference to `GUID_Key' /usr/local/cross-tools/x86_64-w64-mingw32/lib/libSDL.a(SDL_dx5video.o):SDL_dx5video.c:(.data+0x6b8): undefined reference to `GUID_Key' /usr/local/cross-tools/x86_64-w64-mingw32/lib/libSDL.a(SDL_dx5video.o):SDL_dx5video.c:(.data+0x6d0): undefined reference to `GUID_Key' /usr/local/cross-tools/x86_64-w64-mingw32/lib/libSDL.a(SDL_dx5video.o):SDL_dx5video.c:(.data+0x6e8): undefined reference to `GUID_Key' /usr/local/cross-tools/x86_64-w64-mingw32/lib/libSDL.a(SDL_dx5video.o):SDL_dx5video.c:(.data+0x700): undefined reference to `GUID_Key' /usr/local/cross-tools/x86_64-w64-mingw32/lib/libSDL.a(SDL_dx5video.o):SDL_dx5video.c:(.data+0x718): more undefined references to `GUID_Key' follow /usr/local/cross-tools/x86_64-w64-mingw32/lib/libSDL.a(SDL_mmjoystick.o):SDL_mmjoystick.c:(.text+0x40): undefined reference to `__imp_joyGetNumDevs' /usr/local/cross-tools/x86_64-w64-mingw32/lib/libSDL.a(SDL_mmjoystick.o):SDL_mmjoystick.c:(.text+0x84): undefined reference to `__imp_joyGetPosEx' /usr/local/cross-tools/x86_64-w64-mingw32/lib/libSDL.a(SDL_mmjoystick.o):SDL_mmjoystick.c:(.text+0xd0): undefined reference to `__imp_joyGetDevCapsA' /usr/local/cross-tools/x86_64-w64-mingw32/lib/libSDL.a(SDL_mmjoystick.o):SDL_mmjoystick.c:(.text+0x61b): undefined reference to `__imp_joyGetPosEx' /usr/local/cross-tools/x86_64-w64-mingw32/lib/libSDL.a(SDL_syscdrom.o):SDL_syscdrom.c:(.text+0x29): undefined reference to `__imp_mciSendCommandA' /usr/local/cross-tools/x86_64-w64-mingw32/lib/libSDL.a(SDL_syscdrom.o):SDL_syscdrom.c:(.text+0x4d): undefined reference to `__imp_mciGetErrorStringA' /usr/local/cross-tools/x86_64-w64-mingw32/lib/libSDL.a(SDL_dibaudio.o):SDL_dibaudio.c:(.text+0x17f): undefined reference to `__imp_waveOutClose' /usr/local/cross-tools/x86_64-w64-mingw32/lib/libSDL.a(SDL_dibaudio.o):SDL_dibaudio.c:(.text+0x1a3): undefined reference to `__imp_waveOutUnprepareHeader' /usr/local/cross-tools/x86_64-w64-mingw32/lib/libSDL.a(SDL_dibaudio.o):SDL_dibaudio.c:(.text+0x1cf): undefined reference to `__imp_waveOutUnprepareHeader' /usr/local/cross-tools/x86_64-w64-mingw32/lib/libSDL.a(SDL_dibaudio.o):SDL_dibaudio.c:(.text+0x27b): undefined reference to `__imp_waveOutWrite' /usr/local/cross-tools/x86_64-w64-mingw32/lib/libSDL.a(SDL_dibaudio.o):SDL_dibaudio.c:(.text+0x360): undefined reference to `__imp_waveOutGetErrorTextA' /usr/local/cross-tools/x86_64-w64-mingw32/lib/libSDL.a(SDL_dibaudio.o):SDL_dibaudio.c:(.text+0x48f): undefined reference to `__imp_waveOutOpen' /usr/local/cross-tools/x86_64-w64-mingw32/lib/libSDL.a(SDL_dibaudio.o):SDL_dibaudio.c:(.text+0x4e8): undefined reference to `__imp_waveOutPrepareHeader' /usr/local/cross-tools/x86_64-w64-mingw32/lib/libSDL.a(SDL_dx5events.o):SDL_dx5events.c:(.text+0x1461): undefined reference to `IID_IDirectInputDevice2A' /usr/local/cross-tools/x86_64-w64-mingw32/lib/libSDL.a(SDL_dx5events.o):SDL_dx5events.c:(.data+0x8): undefined reference to `GUID_SysKeyboard' /usr/local/cross-tools/x86_64-w64-mingw32/lib/libSDL.a(SDL_dx5events.o):SDL_dx5events.c:(.data+0x30): undefined reference to `GUID_SysMouse' collect2: ld returned 1 exit status make: *** [ffmpeg_g.exe] Error 1
Solution :
Add -lwinmm -lgdi32 -ldxguid
Explanation:
This is a really a rare problem that would occur only when you try to link with libSDL.a static library instead of the dynamic library SDL.dll. Then you have to add those library that SDL.dll normally links against which are the three above.
To view the full article on how to static link SDL into your application visit
It seems you added -static with `sdl-config --libs` in ld conmmand.
Correct ld params should be:
-static `sdl-config --static-libs`
or
`sdl-config --libs`