Compiling SDL2 Application on Windows 7 32bit + MinGW/Msys

Hello ladies and gents,

Just as a note, I’ve came across this issue before and was able to resolve
it by using Visual Studio (rather than mingw), but I don’t know that this
should be necessary.

I’ve written an SDL2 based library, and created a make file:

CC=mingw32-g++

CFLAGS=-O2 -Wall sdl2-config --cflags -I./include
LDFLAGS=sdl2-config --libs -lSDL2_ttf -lopengl32 -lglu32
OTHERFLAGS=-static
SOURCES=application.cpp event.cpp exceptions.cpp thread.cpp window.cpp
EXECUTABLE=sdlui

all:
$(CC) $(OTHERFLAGS) $(CFLAGS) $(LDFLAGS) $(SOURCES) -o $(EXECUTABLE)

clean-executable:
rm -f $(EXECUTABLE)

clean: clean-executable

rebuild: clean all

The output I get, however, is quite bad:

$ mingw32-make -f Makefile.win32

mingw32-g++ -static -O2 -Wall sdl2-config --cflags -I./include
sdl2-config --libs -lSDL2_ttf -lopengl32 -lglu32 application.cpp event.cp
p exceptions.cpp thread.cpp window.cpp -o sdlui
C:/MinGW/msys/1.0/local/lib\libSDL2main.a(SDL_windows_main.o): In function
console_main': c:\Users\Alexander\SDL\x86/../src/main/windows/SDL_windows_main.c:145: undefined reference toSDL_main’
C:\Users\ALEXAN~1\AppData\Local\Temp\ccyTTLzr.o:application.cpp:(.text+0x216):
undefined reference to SDL_PollEvent' C:\Users\ALEXAN~1\AppData\Local\Temp\ccyTTLzr.o:application.cpp:(.text+0x24d): undefined reference toSDL_PollEvent’
C:\Users\ALEXAN~1\AppData\Local\Temp\ccyTTLzr.o:application.cpp:(.text+0x3e7):
undefined reference to SDL_Init' C:\Users\ALEXAN~1\AppData\Local\Temp\ccyTTLzr.o:application.cpp:(.text+0x40c): undefined reference tobarrysoft::FontFactory::getInstance()'
C:\Users\ALEXAN~1\AppData\Local\Temp\ccyTTLzr.o:application.cpp:(.text+0x5cc):
undefined reference to barrysoft::FontFactory::getInstance()' C:\Users\ALEXAN~1\AppData\Local\Temp\ccyTTLzr.o:application.cpp:(.text+0x5da): undefined reference tobarrysoft::FontFactory::~FontFactory()'
C:\Users\ALEXAN~1\AppData\Local\Temp\ccyTTLzr.o:application.cpp:(.text+0x5e7):
undefined reference to SDL_Quit' C:\Users\ALEXAN~1\AppData\Local\Temp\ccHX8h2N.o:exceptions.cpp:(.text+0x3b): undefined reference toglGetError at 0’
C:\Users\ALEXAN~1\AppData\Local\Temp\ccHX8h2N.o:exceptions.cpp:(.text+0xc3d):
undefined reference to SDL_GetError' C:\Users\ALEXAN~1\AppData\Local\Temp\ccHX8h2N.o:exceptions.cpp:(.text+0x15f1): undefined reference toSDL_GetError’
C:\Users\ALEXAN~1\AppData\Local\Temp\ccwWc5Uo.o:thread.cpp:(.text+0xf):
undefined reference to SDL_mutexP' C:\Users\ALEXAN~1\AppData\Local\Temp\ccwWc5Uo.o:thread.cpp:(.text+0x4a): undefined reference toSDL_CreateMutex’
C:\Users\ALEXAN~1\AppData\Local\Temp\ccwWc5Uo.o:thread.cpp:(.text+0x88):
undefined reference to SDL_mutexP' C:\Users\ALEXAN~1\AppData\Local\Temp\ccwWc5Uo.o:thread.cpp:(.text+0x97): undefined reference toSDL_mutexV’
C:\Users\ALEXAN~1\AppData\Local\Temp\ccwWc5Uo.o:thread.cpp:(.text+0xb7):
undefined reference to SDL_mutexP' C:\Users\ALEXAN~1\AppData\Local\Temp\ccwWc5Uo.o:thread.cpp:(.text+0x15a): undefined reference toSDL_mutexV’
C:\Users\ALEXAN~1\AppData\Local\Temp\ccwWc5Uo.o:thread.cpp:(.text+0x162):
undefined reference to SDL_Delay' C:\Users\ALEXAN~1\AppData\Local\Temp\ccwWc5Uo.o:thread.cpp:(.text+0x1ad): undefined reference toSDL_mutexV’
C:\Users\ALEXAN~1\AppData\Local\Temp\ccwWc5Uo.o:thread.cpp:(.text+0x270):
undefined reference to SDL_mutexP' C:\Users\ALEXAN~1\AppData\Local\Temp\ccwWc5Uo.o:thread.cpp:(.text+0x2a0): undefined reference toSDL_mutexV’
C:\Users\ALEXAN~1\AppData\Local\Temp\ccwWc5Uo.o:thread.cpp:(.text+0x35b):
undefined reference to SDL_mutexP' C:\Users\ALEXAN~1\AppData\Local\Temp\ccwWc5Uo.o:thread.cpp:(.text+0x434): undefined reference toSDL_WaitThread’
C:\Users\ALEXAN~1\AppData\Local\Temp\ccwWc5Uo.o:thread.cpp:(.text+0x43f):
undefined reference to SDL_DestroyMutex' C:\Users\ALEXAN~1\AppData\Local\Temp\ccwWc5Uo.o:thread.cpp:(.text+0x4b2): undefined reference toSDL_CreateMutex’
C:\Users\ALEXAN~1\AppData\Local\Temp\ccwWc5Uo.o:thread.cpp:(.text+0x4d1):
undefined reference to SDL_CreateThread' C:\Users\ALEXAN~1\AppData\Local\Temp\ccwWc5Uo.o:thread.cpp:(.text+0x23): undefined reference toSDL_mutexV’
C:\Users\ALEXAN~1\AppData\Local\Temp\ccwWc5Uo.o:thread.cpp:(.text+0x6a):
undefined reference to SDL_DestroyMutex' C:\Users\ALEXAN~1\AppData\Local\Temp\ccwWc5Uo.o:thread.cpp:(.text+0x2b8): undefined reference toSDL_mutexP’
C:\Users\ALEXAN~1\AppData\Local\Temp\ccwWc5Uo.o:thread.cpp:(.text+0x2c8):
undefined reference to SDL_mutexV' C:\Users\ALEXAN~1\AppData\Local\Temp\ccwWc5Uo.o:thread.cpp:(.text+0x389): undefined reference toSDL_mutexV’
C:\Users\ALEXAN~1\AppData\Local\Temp\cccMCOUz.o:window.cpp:(.text+0xe2):
undefined reference to SDL_CreateWindow' C:\Users\ALEXAN~1\AppData\Local\Temp\cccMCOUz.o:window.cpp:(.text+0x175): undefined reference toSDL_SetWindowSize’
C:\Users\ALEXAN~1\AppData\Local\Temp\cccMCOUz.o:window.cpp:(.text+0x1c7):
undefined reference to SDL_SetWindowPosition' C:\Users\ALEXAN~1\AppData\Local\Temp\cccMCOUz.o:window.cpp:(.text+0x211): undefined reference toSDL_GL_DeleteContext’
C:\Users\ALEXAN~1\AppData\Local\Temp\cccMCOUz.o:window.cpp:(.text+0x24c):
undefined reference to glMatrixMode at 4' C:\Users\ALEXAN~1\AppData\Local\Temp\cccMCOUz.o:window.cpp:(.text+0x252): undefined reference toglPushMatrix at 0’
C:\Users\ALEXAN~1\AppData\Local\Temp\cccMCOUz.o:window.cpp:(.text+0x257):
undefined reference to glLoadIdentity at 0' C:\Users\ALEXAN~1\AppData\Local\Temp\cccMCOUz.o:window.cpp:(.text+0x2b3): undefined reference toglOrtho at 48’
C:\Users\ALEXAN~1\AppData\Local\Temp\cccMCOUz.o:window.cpp:(.text+0x2c2):
undefined reference to glMatrixMode at 4' C:\Users\ALEXAN~1\AppData\Local\Temp\cccMCOUz.o:window.cpp:(.text+0x2db): undefined reference toglMatrixMode at 4’
C:\Users\ALEXAN~1\AppData\Local\Temp\cccMCOUz.o:window.cpp:(.text+0x2e1):
undefined reference to glPopMatrix at 0' C:\Users\ALEXAN~1\AppData\Local\Temp\cccMCOUz.o:window.cpp:(.text+0x2ed): undefined reference toglMatrixMode at 4’
C:\Users\ALEXAN~1\AppData\Local\Temp\cccMCOUz.o:window.cpp:(.text+0x30d):
undefined reference to SDL_GL_MakeCurrent' C:\Users\ALEXAN~1\AppData\Local\Temp\cccMCOUz.o:window.cpp:(.text+0x37b): undefined reference toSDL_GL_CreateContext’
C:\Users\ALEXAN~1\AppData\Local\Temp\cccMCOUz.o:window.cpp:(.text+0x392):
undefined reference to SDL_GL_SetSwapInterval' C:\Users\ALEXAN~1\AppData\Local\Temp\cccMCOUz.o:window.cpp:(.text+0x3a6): undefined reference toSDL_GL_SetAttribute’
C:\Users\ALEXAN~1\AppData\Local\Temp\cccMCOUz.o:window.cpp:(.text+0x3ba):
undefined reference to SDL_GL_SetAttribute' C:\Users\ALEXAN~1\AppData\Local\Temp\cccMCOUz.o:window.cpp:(.text+0x3ce): undefined reference toSDL_GL_SetAttribute’
C:\Users\ALEXAN~1\AppData\Local\Temp\cccMCOUz.o:window.cpp:(.text+0x3e2):
undefined reference to SDL_GL_SetAttribute' C:\Users\ALEXAN~1\AppData\Local\Temp\cccMCOUz.o:window.cpp:(.text+0x3f6): undefined reference toSDL_GL_SetAttribute’
C:\Users\ALEXAN~1\AppData\Local\Temp\cccMCOUz.o:window.cpp:(.text+0x40a):
more undefined references to SDL_GL_SetAttribute' follow C:\Users\ALEXAN~1\AppData\Local\Temp\cccMCOUz.o:window.cpp:(.text+0x42e): undefined reference toglClearColor at 16’
C:\Users\ALEXAN~1\AppData\Local\Temp\cccMCOUz.o:window.cpp:(.text+0x455):
undefined reference to glViewport at 16' C:\Users\ALEXAN~1\AppData\Local\Temp\cccMCOUz.o:window.cpp:(.text+0x464): undefined reference toglMatrixMode at 4’
C:\Users\ALEXAN~1\AppData\Local\Temp\cccMCOUz.o:window.cpp:(.text+0x46a):
undefined reference to glLoadIdentity at 0' C:\Users\ALEXAN~1\AppData\Local\Temp\cccMCOUz.o:window.cpp:(.text+0x4af): undefined reference togluPerspective at 32’
C:\Users\ALEXAN~1\AppData\Local\Temp\cccMCOUz.o:window.cpp:(.text+0x4be):
undefined reference to glMatrixMode at 4' C:\Users\ALEXAN~1\AppData\Local\Temp\cccMCOUz.o:window.cpp:(.text+0x4c4): undefined reference toglLoadIdentity at 0’
C:\Users\ALEXAN~1\AppData\Local\Temp\cccMCOUz.o:window.cpp:(.text+0x4d8):
undefined reference to glBlendFunc at 8' C:\Users\ALEXAN~1\AppData\Local\Temp\cccMCOUz.o:window.cpp:(.text+0x4e7): undefined reference toglLineWidth at 4’
C:\Users\ALEXAN~1\AppData\Local\Temp\cccMCOUz.o:window.cpp:(.text+0x4f4):
undefined reference to glEnable at 4' C:\Users\ALEXAN~1\AppData\Local\Temp\cccMCOUz.o:window.cpp:(.text+0x501): undefined reference toglEnable at 4’
C:\Users\ALEXAN~1\AppData\Local\Temp\cccMCOUz.o:window.cpp:(.text+0x50e):
undefined reference to glGetString at 4' C:\Users\ALEXAN~1\AppData\Local\Temp\cccMCOUz.o:window.cpp:(.text+0x51f): undefined reference toglGetString at 4’
C:\Users\ALEXAN~1\AppData\Local\Temp\cccMCOUz.o:window.cpp:(.text+0x52e):
undefined reference to glGetString at 4' C:\Users\ALEXAN~1\AppData\Local\Temp\cccMCOUz.o:window.cpp:(.text+0x100): undefined reference toSDL_GetWindowPosition’
C:\Users\ALEXAN~1\AppData\Local\Temp\cccMCOUz.o:window.cpp:(.text+0x116):
undefined reference to SDL_DestroyWindow' C:\Users\ALEXAN~1\AppData\Local\Temp\cccMCOUz.o:window.cpp:(.text+0x130): undefined reference toSDL_GetWindowID’
C:\Users\ALEXAN~1\AppData\Local\Temp\cccMCOUz.o:window.cpp:(.text+0x140):
undefined reference to SDL_ShowWindow' C:\Users\ALEXAN~1\AppData\Local\Temp\cccMCOUz.o:window.cpp:(.text+0x150): undefined reference toSDL_HideWindow’
C:\Users\ALEXAN~1\AppData\Local\Temp\cccMCOUz.o:window.cpp:(.text+0x1e5):
undefined reference to SDL_GetWindowPosition' C:\Users\ALEXAN~1\AppData\Local\Temp\cccMCOUz.o:window.cpp:(.text+0x1f8): undefined reference toSDL_GetWindowID’
C:\Users\ALEXAN~1\AppData\Local\Temp\cccMCOUz.o:window.cpp:(.text+0x2cc):
undefined reference to `glLoadIdentity at 0’
collect2: ld returned 1 exit status
mingw32-make: *** [all] Error 1

So, first thing I thought was the sdl2-config was giving bad output, so I
did sdl2-config --libs --cflags and got this:

$ sdl2-config --libs --cflags
-L/usr/local/lib -lmingw32 -lSDL2main -lSDL2 -mwindows
-I/usr/local/include/SDL2 -Dmain=SDL_main

The directories and libraries are all correct.

So, now I’m down to a few options. Either I broke my mingw/msys config
(which is possible), or SDL2 broke mingw32 builds.

Anyone else with experience with the latest SDL2 from hg (just pulled this
morning) and mingw32? If anyone else has built it, then I’ll try
re-installing mingw32 to see if that fixes it.

Thanks,
-Alex

The output I get, however, is quite bad:

$ mingw32-make -f Makefile.win32

mingw32-g++ -static -O2 -Wall sdl2-config --cflags -I./include
sdl2-config --libs -lSDL2_ttf -lopengl32 -lglu32 application.cpp event.cp
p exceptions.cpp thread.cpp window.cpp -o sdlui
C:/MinGW/msys/1.0/local/lib\libSDL2main.a(SDL_windows_main.o): In
function console_main': c:\Users\Alexander\SDL\x86/../src/main/windows/SDL_windows_main.c:145: undefined reference toSDL_main’

Can you try running mingw32-g++ -static -O2 -Wall sdl2-config --cflags
-I./include -lSDL2_ttf -lopengl32 -lglu32 application.cpp event.cpp
exceptions.cpp thread.cpp window.cpp -o sdlui sdl2-config --libs

That is with the SDL2 libraries at the end of the command line, if you
updated MingW32 recently it’s possible they’ve switched GCC versions and
the dependency solving “feature/bug” is causing those unresolved symbols.–
Gabriel.

That gives me a bunch of different errors, but it does link to SDL:

$ mingw32-make -f Makefile.win32

mingw32-g++ -static -O2 -Wall sdl2-config --cflags -I./include
-lSDL2_ttf -lopengl32 -lglu32 application.cpp event.cpp exceptions.cpp thre
ad.cpp window.cpp sdl2-config --libs
C:\Users\ALEXAN~1\AppData\Local\Temp\ccIHv7Y9.o:application.cpp:(.text+0x40c):
undefined reference to barrysoft::FontFactory::getInstance()' C:\Users\ALEXAN~1\AppData\Local\Temp\ccIHv7Y9.o:application.cpp:(.text+0x5cc): undefined reference tobarrysoft::FontFactory::getInstance()‘
C:\Users\ALEXAN~1\AppData\Local\Temp\ccIHv7Y9.o:application.cpp:(.text+0x5da):
undefined reference to barrysoft::FontFactory::~FontFactory()' C:\Users\ALEXAN~1\AppData\Local\Temp\ccHl0o9i.o:exceptions.cpp:(.text+0x3b): undefined reference toglGetError at 0’
C:\Users\ALEXAN~1\AppData\Local\Temp\ccG2UubQ.o:window.cpp:(.text+0x24c):
undefined reference to glMatrixMode at 4' C:\Users\ALEXAN~1\AppData\Local\Temp\ccG2UubQ.o:window.cpp:(.text+0x252): undefined reference toglPushMatrix at 0’
C:\Users\ALEXAN~1\AppData\Local\Temp\ccG2UubQ.o:window.cpp:(.text+0x257):
undefined reference to glLoadIdentity at 0' C:\Users\ALEXAN~1\AppData\Local\Temp\ccG2UubQ.o:window.cpp:(.text+0x2b3): undefined reference toglOrtho at 48’
C:\Users\ALEXAN~1\AppData\Local\Temp\ccG2UubQ.o:window.cpp:(.text+0x2c2):
undefined reference to glMatrixMode at 4' C:\Users\ALEXAN~1\AppData\Local\Temp\ccG2UubQ.o:window.cpp:(.text+0x2db): undefined reference toglMatrixMode at 4’
C:\Users\ALEXAN~1\AppData\Local\Temp\ccG2UubQ.o:window.cpp:(.text+0x2e1):
undefined reference to glPopMatrix at 0' C:\Users\ALEXAN~1\AppData\Local\Temp\ccG2UubQ.o:window.cpp:(.text+0x2ed): undefined reference toglMatrixMode at 4’
C:\Users\ALEXAN~1\AppData\Local\Temp\ccG2UubQ.o:window.cpp:(.text+0x42e):
undefined reference to glClearColor at 16' C:\Users\ALEXAN~1\AppData\Local\Temp\ccG2UubQ.o:window.cpp:(.text+0x455): undefined reference toglViewport at 16’
C:\Users\ALEXAN~1\AppData\Local\Temp\ccG2UubQ.o:window.cpp:(.text+0x464):
undefined reference to glMatrixMode at 4' C:\Users\ALEXAN~1\AppData\Local\Temp\ccG2UubQ.o:window.cpp:(.text+0x46a): undefined reference toglLoadIdentity at 0’
C:\Users\ALEXAN~1\AppData\Local\Temp\ccG2UubQ.o:window.cpp:(.text+0x4af):
undefined reference to gluPerspective at 32' C:\Users\ALEXAN~1\AppData\Local\Temp\ccG2UubQ.o:window.cpp:(.text+0x4be): undefined reference toglMatrixMode at 4’
C:\Users\ALEXAN~1\AppData\Local\Temp\ccG2UubQ.o:window.cpp:(.text+0x4c4):
undefined reference to glLoadIdentity at 0' C:\Users\ALEXAN~1\AppData\Local\Temp\ccG2UubQ.o:window.cpp:(.text+0x4d8): undefined reference toglBlendFunc at 8’
C:\Users\ALEXAN~1\AppData\Local\Temp\ccG2UubQ.o:window.cpp:(.text+0x4e7):
undefined reference to glLineWidth at 4' C:\Users\ALEXAN~1\AppData\Local\Temp\ccG2UubQ.o:window.cpp:(.text+0x4f4): undefined reference toglEnable at 4’
C:\Users\ALEXAN~1\AppData\Local\Temp\ccG2UubQ.o:window.cpp:(.text+0x501):
undefined reference to glEnable at 4' C:\Users\ALEXAN~1\AppData\Local\Temp\ccG2UubQ.o:window.cpp:(.text+0x50e): undefined reference toglGetString at 4’
C:\Users\ALEXAN~1\AppData\Local\Temp\ccG2UubQ.o:window.cpp:(.text+0x51f):
undefined reference to glGetString at 4' C:\Users\ALEXAN~1\AppData\Local\Temp\ccG2UubQ.o:window.cpp:(.text+0x52e): undefined reference toglGetString at 4’
C:\Users\ALEXAN~1\AppData\Local\Temp\ccG2UubQ.o:window.cpp:(.text+0x2cc):
undefined reference to glLoadIdentity at 0' C:/MinGW/msys/1.0/local/lib\libSDL2main.a(SDL_windows_main.o): In functionconsole_main’:
c:\Users\Alexander\SDL\x86/…/src/main/windows/SDL_windows_main.c:145:
undefined reference to SDL_main' C:/MinGW/msys/1.0/local/lib\libSDL2.a(SDL_systimer.o): In functionSDL_StartTicks’:
c:\Users\Alexander\SDL\x86/…/src/timer/windows/SDL_systimer.c:63:
undefined reference to timeBeginPeriod at 4' c:\Users\Alexander\SDL\x86/../src/timer/windows/SDL_systimer.c:64: undefined reference totimeGetTime at 0’
C:/MinGW/msys/1.0/local/lib\libSDL2.a(SDL_systimer.o): In function
SDL_GetTicks': c:\Users\Alexander\SDL\x86/../src/timer/windows/SDL_systimer.c:89: undefined reference totimeGetTime at 0’
C:/MinGW/msys/1.0/local/lib\libSDL2.a(SDL_dxjoystick.o): In function
SDL_SYS_JoystickInit': c:\Users\Alexander\SDL\x86/../src/joystick/windows/SDL_dxjoystick.c:297: undefined reference toCoCreateInstance at 20’
C:/MinGW/msys/1.0/local/lib\libSDL2.a(SDL_winmm.o): In function
WINMM_CloseDevice': c:\Users\Alexander\SDL\x86/../src/audio/winmm/SDL_winmm.c:185: undefined reference towaveInClose at 4’
c:\Users\Alexander\SDL\x86/…/src/audio/winmm/SDL_winmm.c:190: undefined
reference to waveOutClose at 4' c:\Users\Alexander\SDL\x86/../src/audio/winmm/SDL_winmm.c:197: undefined reference towaveOutUnprepareHeader at 12’
c:\Users\Alexander\SDL\x86/…/src/audio/winmm/SDL_winmm.c:197: undefined
reference to waveOutUnprepareHeader at 12' C:/MinGW/msys/1.0/local/lib\libSDL2.a(SDL_winmm.o): In functionWINMM_PlayDevice’:
c:\Users\Alexander\SDL\x86/…/src/audio/winmm/SDL_winmm.c:144: undefined
reference to waveOutWrite at 12' C:/MinGW/msys/1.0/local/lib\libSDL2.a(SDL_winmm.o): In functionDetectWaveInDevs’:
c:\Users\Alexander\SDL\x86/…/src/audio/winmm/SDL_winmm.c:55: undefined
reference to waveInGetNumDevs at 0' c:\Users\Alexander\SDL\x86/../src/audio/winmm/SDL_winmm.c:55: undefined reference towaveInGetDevCapsW at 12’
C:/MinGW/msys/1.0/local/lib\libSDL2.a(SDL_winmm.o): In function
DetectWaveOutDevs': c:\Users\Alexander\SDL\x86/../src/audio/winmm/SDL_winmm.c:54: undefined reference towaveOutGetNumDevs at 0’
c:\Users\Alexander\SDL\x86/…/src/audio/winmm/SDL_winmm.c:54: undefined
reference to waveOutGetDevCapsW at 12' C:/MinGW/msys/1.0/local/lib\libSDL2.a(SDL_winmm.o): In functionWINMM_OpenDevice’:
c:\Users\Alexander\SDL\x86/…/src/audio/winmm/SDL_winmm.c:228: undefined
reference to waveInGetNumDevs at 0' c:\Users\Alexander\SDL\x86/../src/audio/winmm/SDL_winmm.c:231: undefined reference towaveInGetDevCapsW at 12’
c:\Users\Alexander\SDL\x86/…/src/audio/winmm/SDL_winmm.c:241: undefined
reference to waveOutGetNumDevs at 0' c:\Users\Alexander\SDL\x86/../src/audio/winmm/SDL_winmm.c:244: undefined reference towaveOutGetDevCapsW at 12’
c:\Users\Alexander\SDL\x86/…/src/audio/winmm/SDL_winmm.c:320: undefined
reference to waveInOpen at 24' c:\Users\Alexander\SDL\x86/../src/audio/winmm/SDL_winmm.c:378: undefined reference towaveOutPrepareHeader at 12’
c:\Users\Alexander\SDL\x86/…/src/audio/winmm/SDL_winmm.c:378: undefined
reference to waveOutPrepareHeader at 12' c:\Users\Alexander\SDL\x86/../src/audio/winmm/SDL_winmm.c:324: undefined reference towaveOutOpen at 24’
C:/MinGW/msys/1.0/local/lib\libSDL2.a(SDL_winmm.o): In function
SetMMerror': c:\Users\Alexander\SDL\x86/../src/audio/winmm/SDL_winmm.c:115: undefined reference towaveOutGetErrorTextW at 12’
c:\Users\Alexander\SDL\x86/…/src/audio/winmm/SDL_winmm.c:115: undefined
reference to waveOutGetErrorTextW at 12' C:/MinGW/msys/1.0/local/lib\libSDL2.a(SDL_syshaptic.o): In functionSDL_SYS_HapticInit’:
c:\Users\Alexander\SDL\x86/…/src/haptic/windows/SDL_syshaptic.c:159:
undefined reference to CoCreateInstance at 20' C:/MinGW/msys/1.0/local/lib\libSDL2.a(SDL_windows.o): In functionWIN_CoInitialize’:
c:\Users\Alexander\SDL\x86/…/src/core/windows/SDL_windows.c:47: undefined
reference to CoInitialize at 4' C:/MinGW/msys/1.0/local/lib\libSDL2.a(SDL_windows.o): In functionWIN_CoUninitialize’:
c:\Users\Alexander\SDL\x86/…/src/core/windows/SDL_windows.c:61: undefined
reference to CoUninitialize at 0' C:/MinGW/msys/1.0/local/lib\libSDL2.a(SDL_windowskeyboard.o): In functionIPPASink_QueryInterface at 12’:
c:\Users\Alexander\SDL\x86/…/src/video/windows/SDL_windowskeyboard.c:1122:
undefined reference to IID_IUnknown' C:/MinGW/msys/1.0/local/lib\libSDL2.a(SDL_windowskeyboard.o): In functionUIElementSink_QueryInterface at 12’:
c:\Users\Alexander\SDL\x86/…/src/video/windows/SDL_windowskeyboard.c:1015:
undefined reference to IID_IUnknown' C:/MinGW/msys/1.0/local/lib\libSDL2.a(SDL_windowskeyboard.o): In functionUILess_GetCandidateList’:
c:\Users\Alexander\SDL\x86/…/src/video/windows/SDL_windowskeyboard.c:986:
undefined reference to SysFreeString at 4' C:/MinGW/msys/1.0/local/lib\libSDL2.a(SDL_windowskeyboard.o): In functionIME_GetId’:
c:\Users\Alexander\SDL\x86/…/src/video/windows/SDL_windowskeyboard.c:551:
undefined reference to ImmGetIMEFileNameA at 12' c:\Users\Alexander\SDL\x86/../src/video/windows/SDL_windowskeyboard.c:566: undefined reference toGetFileVersionInfoSizeA at 8’
c:\Users\Alexander\SDL\x86/…/src/video/windows/SDL_windowskeyboard.c:570:
undefined reference to GetFileVersionInfoA at 16' c:\Users\Alexander\SDL\x86/../src/video/windows/SDL_windowskeyboard.c:571: undefined reference toVerQueryValueA at 16’
C:/MinGW/msys/1.0/local/lib\libSDL2.a(SDL_windowskeyboard.o): In function
IME_SetupAPI': c:\Users\Alexander\SDL\x86/../src/video/windows/SDL_windowskeyboard.c:617: undefined reference toImmGetIMEFileNameA at 12’
c:\Users\Alexander\SDL\x86/…/src/video/windows/SDL_windowskeyboard.c:630:
undefined reference to ImmGetContext at 4' c:\Users\Alexander\SDL\x86/../src/video/windows/SDL_windowskeyboard.c:633: undefined reference toImmReleaseContext at 8’
C:/MinGW/msys/1.0/local/lib\libSDL2.a(SDL_windowskeyboard.o): In function
IME_ClearComposition': c:\Users\Alexander\SDL\x86/../src/video/windows/SDL_windowskeyboard.c:683: undefined reference toImmGetContext at 4’
c:\Users\Alexander\SDL\x86/…/src/video/windows/SDL_windowskeyboard.c:687:
undefined reference to ImmNotifyIME at 16' c:\Users\Alexander\SDL\x86/../src/video/windows/SDL_windowskeyboard.c:691: undefined reference toImmNotifyIME at 16’
c:\Users\Alexander\SDL\x86/…/src/video/windows/SDL_windowskeyboard.c:692:
undefined reference to ImmReleaseContext at 8' c:\Users\Alexander\SDL\x86/../src/video/windows/SDL_windowskeyboard.c:689: undefined reference toImmSetCompositionStringW at 24’
C:/MinGW/msys/1.0/local/lib\libSDL2.a(SDL_windowskeyboard.o): In function
IME_Disable': c:\Users\Alexander\SDL\x86/../src/video/windows/SDL_windowskeyboard.c:367: undefined reference toImmAssociateContext at 8’
C:/MinGW/msys/1.0/local/lib\libSDL2.a(SDL_windowskeyboard.o): In function
IME_Init': c:\Users\Alexander\SDL\x86/../src/video/windows/SDL_windowskeyboard.c:326: undefined reference toImmGetContext at 4’
c:\Users\Alexander\SDL\x86/…/src/video/windows/SDL_windowskeyboard.c:327:
undefined reference to ImmReleaseContext at 8' C:/MinGW/msys/1.0/local/lib\libSDL2.a(SDL_windowskeyboard.o): In functionUILess_SetupSinks’:
c:\Users\Alexander\SDL\x86/…/src/video/windows/SDL_windowskeyboard.c:1195:
undefined reference to CoCreateInstance at 20' C:/MinGW/msys/1.0/local/lib\libSDL2.a(SDL_windowskeyboard.o): In functionUIElementSink_BeginUIElement at 12’:
c:\Users\Alexander\SDL\x86/…/src/video/windows/SDL_windowskeyboard.c:1054:
undefined reference to SysFreeString at 4' C:/MinGW/msys/1.0/local/lib\libSDL2.a(SDL_windowskeyboard.o): In functionUIElementSink_UpdateUIElement at 8’:
c:\Users\Alexander\SDL\x86/…/src/video/windows/SDL_windowskeyboard.c:1081:
undefined reference to SysFreeString at 4' C:/MinGW/msys/1.0/local/lib\libSDL2.a(SDL_windowskeyboard.o): In functionIME_Quit’:
c:\Users\Alexander\SDL\x86/…/src/video/windows/SDL_windowskeyboard.c:381:
undefined reference to ImmAssociateContext at 8' C:/MinGW/msys/1.0/local/lib\libSDL2.a(SDL_windowskeyboard.o): In functionIME_Init’:
c:\Users\Alexander\SDL\x86/…/src/video/windows/SDL_windowskeyboard.c:312:
undefined reference to CoCreateInstance at 20' C:/MinGW/msys/1.0/local/lib\libSDL2.a(SDL_windowskeyboard.o): In functionIME_Enable’:
c:\Users\Alexander\SDL\x86/…/src/video/windows/SDL_windowskeyboard.c:352:
undefined reference to ImmAssociateContext at 8' C:/MinGW/msys/1.0/local/lib\libSDL2.a(SDL_windowskeyboard.o): In functionIME_Init’:
c:\Users\Alexander\SDL\x86/…/src/video/windows/SDL_windowskeyboard.c:312:
undefined reference to CoCreateInstance at 20' C:/MinGW/msys/1.0/local/lib\libSDL2.a(SDL_windowskeyboard.o): In functionIME_HandleMessage’:
c:\Users\Alexander\SDL\x86/…/src/video/windows/SDL_windowskeyboard.c:854:
undefined reference to ImmGetContext at 4' C:/MinGW/msys/1.0/local/lib\libSDL2.a(SDL_windowskeyboard.o): In functionIME_GetCompositionString’:
c:\Users\Alexander\SDL\x86/…/src/video/windows/SDL_windowskeyboard.c:699:
undefined reference to ImmGetCompositionStringW at 16' c:\Users\Alexander\SDL\x86/../src/video/windows/SDL_windowskeyboard.c:704: undefined reference toImmGetCompositionStringW at 16’
C:/MinGW/msys/1.0/local/lib\libSDL2.a(SDL_windowskeyboard.o): In function
IME_HandleMessage': c:\Users\Alexander\SDL\x86/../src/video/windows/SDL_windowskeyboard.c:892: undefined reference toImmReleaseContext at 8’
c:\Users\Alexander\SDL\x86/…/src/video/windows/SDL_windowskeyboard.c:887:
undefined reference to ImmGetContext at 4' C:/MinGW/msys/1.0/local/lib\libSDL2.a(SDL_windowskeyboard.o): In functionIME_GetCandidateList’:
c:\Users\Alexander\SDL\x86/…/src/video/windows/SDL_windowskeyboard.c:766:
undefined reference to ImmGetCandidateListW at 16' C:/MinGW/msys/1.0/local/lib\libSDL2.a(SDL_windowskeyboard.o): In functionIME_GetCompositionString’:
c:\Users\Alexander\SDL\x86/…/src/video/windows/SDL_windowskeyboard.c:699:
undefined reference to ImmGetCompositionStringW at 16' c:\Users\Alexander\SDL\x86/../src/video/windows/SDL_windowskeyboard.c:704: undefined reference toImmGetCompositionStringW at 16’
C:/MinGW/msys/1.0/local/lib\libSDL2.a(SDL_windowskeyboard.o): In function
IME_GetReadingString': c:\Users\Alexander\SDL\x86/../src/video/windows/SDL_windowskeyboard.c:425: undefined reference toImmGetContext at 4’
c:\Users\Alexander\SDL\x86/…/src/video/windows/SDL_windowskeyboard.c:498:
undefined reference to ImmReleaseContext at 8' C:/MinGW/msys/1.0/local/lib\libSDL2.a(SDL_windowskeyboard.o): In functionIME_GetCandidateList’:
c:\Users\Alexander\SDL\x86/…/src/video/windows/SDL_windowskeyboard.c:770:
undefined reference to `ImmGetCandidateListW at 16’
collect2: ld returned 1 exit status
mingw32-make: *** [all] Error 1

Not sure how to fix this either, but we’re moving in the right direction :slight_smile:
-AlexOn Sat, Aug 11, 2012 at 1:20 PM, Gabriel Jacobo wrote:

The output I get, however, is quite bad:

$ mingw32-make -f Makefile.win32

mingw32-g++ -static -O2 -Wall sdl2-config --cflags -I./include
sdl2-config --libs -lSDL2_ttf -lopengl32 -lglu32 application.cpp event.cp
p exceptions.cpp thread.cpp window.cpp -o sdlui
C:/MinGW/msys/1.0/local/lib\libSDL2main.a(SDL_windows_main.o): In
function console_main': c:\Users\Alexander\SDL\x86/../src/main/windows/SDL_windows_main.c:145: undefined reference toSDL_main’

Can you try running mingw32-g++ -static -O2 -Wall sdl2-config --cflags
-I./include -lSDL2_ttf -lopengl32 -lglu32 application.cpp event.cpp
exceptions.cpp thread.cpp window.cpp -o sdlui sdl2-config --libs

That is with the SDL2 libraries at the end of the command line, if you
updated MingW32 recently it’s possible they’ve switched GCC versions and
the dependency solving “feature/bug” is causing those unresolved symbols.


Gabriel.


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

2012/8/11 Alex Barry <alex.barry at gmail.com>

That gives me a bunch of different errors, but it does link to SDL:

$ mingw32-make -f Makefile.win32

mingw32-g++ -static -O2 -Wall sdl2-config --cflags -I./include
-lSDL2_ttf -lopengl32 -lglu32 application.cpp event.cpp exceptions.cpp thre
ad.cpp window.cpp sdl2-config --libs
mingw32-make: *** [all] Error 1

Not sure how to fix this either, but we’re moving in the right direction :slight_smile:
-Alex

The solution is to start rearranging your command so libraries that depend
on others appear first (in a left to right order) in the command line…

So, as SDL2_ttf depends on SDL2, you’d put it first. After SDL2 you’d put
opengl32 because SDL2 will be using it,etc. It may be even possible you’ll
need to list a library twice.–
Gabriel.

Just a note to other people who come across this thread, what I ended up
doing was reverting to an older version of gcc and g++ by doing the
following in the msys shell:

$ mingw-get install gcc-v3-core
$ mingw-get install gcc-v3-c++

Note: This will change the default gcc version on your system - if you want
to return to gcc 4.x (I think the names may change in the eventual future
of gcc 5.x), do:
$ mingw-get install gcc-core
$ mingw-get install gcc-c++

Then, I was originally trying to build a static library, which was still
giving me issues in gcc 3.x, so I tried building with -shared rather than
-static, and everything built fine.

Gabriel, thanks for the troubleshooting - I’ve been doing a lot of windows
development for work lately and haven’t touched gcc in a while. I’m sort
of surprised at how messed up the linker is in gcc 4.5.x, but maybe that’s
intentional in some sense? I don’t know, but anyway, thanks for the help!

Hope that helps someone else down the road, too,
-AlexOn Sat, Aug 11, 2012 at 3:42 PM, Gabriel Jacobo wrote:

2012/8/11 Alex Barry <@Alex_Barry>

That gives me a bunch of different errors, but it does link to SDL:

$ mingw32-make -f Makefile.win32

mingw32-g++ -static -O2 -Wall sdl2-config --cflags -I./include
-lSDL2_ttf -lopengl32 -lglu32 application.cpp event.cpp exceptions.cpp thre
ad.cpp window.cpp sdl2-config --libs
mingw32-make: *** [all] Error 1

Not sure how to fix this either, but we’re moving in the right direction
:slight_smile:
-Alex

The solution is to start rearranging your command so libraries that depend
on others appear first (in a left to right order) in the command line…

So, as SDL2_ttf depends on SDL2, you’d put it first. After SDL2 you’d put
opengl32 because SDL2 will be using it,etc. It may be even possible you’ll
need to list a library twice.


Gabriel.


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org