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=sdluiall:
$(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 to
SDL_main’
C:\Users\ALEXAN~1\AppData\Local\Temp\ccyTTLzr.o:application.cpp:(.text+0x216):
undefined reference toSDL_PollEvent' C:\Users\ALEXAN~1\AppData\Local\Temp\ccyTTLzr.o:application.cpp:(.text+0x24d): undefined reference to
SDL_PollEvent’
C:\Users\ALEXAN~1\AppData\Local\Temp\ccyTTLzr.o:application.cpp:(.text+0x3e7):
undefined reference toSDL_Init' C:\Users\ALEXAN~1\AppData\Local\Temp\ccyTTLzr.o:application.cpp:(.text+0x40c): undefined reference to
barrysoft::FontFactory::getInstance()'
C:\Users\ALEXAN~1\AppData\Local\Temp\ccyTTLzr.o:application.cpp:(.text+0x5cc):
undefined reference tobarrysoft::FontFactory::getInstance()' C:\Users\ALEXAN~1\AppData\Local\Temp\ccyTTLzr.o:application.cpp:(.text+0x5da): undefined reference to
barrysoft::FontFactory::~FontFactory()'
C:\Users\ALEXAN~1\AppData\Local\Temp\ccyTTLzr.o:application.cpp:(.text+0x5e7):
undefined reference toSDL_Quit' C:\Users\ALEXAN~1\AppData\Local\Temp\ccHX8h2N.o:exceptions.cpp:(.text+0x3b): undefined reference to
glGetError at 0’
C:\Users\ALEXAN~1\AppData\Local\Temp\ccHX8h2N.o:exceptions.cpp:(.text+0xc3d):
undefined reference toSDL_GetError' C:\Users\ALEXAN~1\AppData\Local\Temp\ccHX8h2N.o:exceptions.cpp:(.text+0x15f1): undefined reference to
SDL_GetError’
C:\Users\ALEXAN~1\AppData\Local\Temp\ccwWc5Uo.o:thread.cpp:(.text+0xf):
undefined reference toSDL_mutexP' C:\Users\ALEXAN~1\AppData\Local\Temp\ccwWc5Uo.o:thread.cpp:(.text+0x4a): undefined reference to
SDL_CreateMutex’
C:\Users\ALEXAN~1\AppData\Local\Temp\ccwWc5Uo.o:thread.cpp:(.text+0x88):
undefined reference toSDL_mutexP' C:\Users\ALEXAN~1\AppData\Local\Temp\ccwWc5Uo.o:thread.cpp:(.text+0x97): undefined reference to
SDL_mutexV’
C:\Users\ALEXAN~1\AppData\Local\Temp\ccwWc5Uo.o:thread.cpp:(.text+0xb7):
undefined reference toSDL_mutexP' C:\Users\ALEXAN~1\AppData\Local\Temp\ccwWc5Uo.o:thread.cpp:(.text+0x15a): undefined reference to
SDL_mutexV’
C:\Users\ALEXAN~1\AppData\Local\Temp\ccwWc5Uo.o:thread.cpp:(.text+0x162):
undefined reference toSDL_Delay' C:\Users\ALEXAN~1\AppData\Local\Temp\ccwWc5Uo.o:thread.cpp:(.text+0x1ad): undefined reference to
SDL_mutexV’
C:\Users\ALEXAN~1\AppData\Local\Temp\ccwWc5Uo.o:thread.cpp:(.text+0x270):
undefined reference toSDL_mutexP' C:\Users\ALEXAN~1\AppData\Local\Temp\ccwWc5Uo.o:thread.cpp:(.text+0x2a0): undefined reference to
SDL_mutexV’
C:\Users\ALEXAN~1\AppData\Local\Temp\ccwWc5Uo.o:thread.cpp:(.text+0x35b):
undefined reference toSDL_mutexP' C:\Users\ALEXAN~1\AppData\Local\Temp\ccwWc5Uo.o:thread.cpp:(.text+0x434): undefined reference to
SDL_WaitThread’
C:\Users\ALEXAN~1\AppData\Local\Temp\ccwWc5Uo.o:thread.cpp:(.text+0x43f):
undefined reference toSDL_DestroyMutex' C:\Users\ALEXAN~1\AppData\Local\Temp\ccwWc5Uo.o:thread.cpp:(.text+0x4b2): undefined reference to
SDL_CreateMutex’
C:\Users\ALEXAN~1\AppData\Local\Temp\ccwWc5Uo.o:thread.cpp:(.text+0x4d1):
undefined reference toSDL_CreateThread' C:\Users\ALEXAN~1\AppData\Local\Temp\ccwWc5Uo.o:thread.cpp:(.text+0x23): undefined reference to
SDL_mutexV’
C:\Users\ALEXAN~1\AppData\Local\Temp\ccwWc5Uo.o:thread.cpp:(.text+0x6a):
undefined reference toSDL_DestroyMutex' C:\Users\ALEXAN~1\AppData\Local\Temp\ccwWc5Uo.o:thread.cpp:(.text+0x2b8): undefined reference to
SDL_mutexP’
C:\Users\ALEXAN~1\AppData\Local\Temp\ccwWc5Uo.o:thread.cpp:(.text+0x2c8):
undefined reference toSDL_mutexV' C:\Users\ALEXAN~1\AppData\Local\Temp\ccwWc5Uo.o:thread.cpp:(.text+0x389): undefined reference to
SDL_mutexV’
C:\Users\ALEXAN~1\AppData\Local\Temp\cccMCOUz.o:window.cpp:(.text+0xe2):
undefined reference toSDL_CreateWindow' C:\Users\ALEXAN~1\AppData\Local\Temp\cccMCOUz.o:window.cpp:(.text+0x175): undefined reference to
SDL_SetWindowSize’
C:\Users\ALEXAN~1\AppData\Local\Temp\cccMCOUz.o:window.cpp:(.text+0x1c7):
undefined reference toSDL_SetWindowPosition' C:\Users\ALEXAN~1\AppData\Local\Temp\cccMCOUz.o:window.cpp:(.text+0x211): undefined reference to
SDL_GL_DeleteContext’
C:\Users\ALEXAN~1\AppData\Local\Temp\cccMCOUz.o:window.cpp:(.text+0x24c):
undefined reference toglMatrixMode at 4' C:\Users\ALEXAN~1\AppData\Local\Temp\cccMCOUz.o:window.cpp:(.text+0x252): undefined reference to
glPushMatrix at 0’
C:\Users\ALEXAN~1\AppData\Local\Temp\cccMCOUz.o:window.cpp:(.text+0x257):
undefined reference toglLoadIdentity at 0' C:\Users\ALEXAN~1\AppData\Local\Temp\cccMCOUz.o:window.cpp:(.text+0x2b3): undefined reference to
glOrtho at 48’
C:\Users\ALEXAN~1\AppData\Local\Temp\cccMCOUz.o:window.cpp:(.text+0x2c2):
undefined reference toglMatrixMode at 4' C:\Users\ALEXAN~1\AppData\Local\Temp\cccMCOUz.o:window.cpp:(.text+0x2db): undefined reference to
glMatrixMode at 4’
C:\Users\ALEXAN~1\AppData\Local\Temp\cccMCOUz.o:window.cpp:(.text+0x2e1):
undefined reference toglPopMatrix at 0' C:\Users\ALEXAN~1\AppData\Local\Temp\cccMCOUz.o:window.cpp:(.text+0x2ed): undefined reference to
glMatrixMode at 4’
C:\Users\ALEXAN~1\AppData\Local\Temp\cccMCOUz.o:window.cpp:(.text+0x30d):
undefined reference toSDL_GL_MakeCurrent' C:\Users\ALEXAN~1\AppData\Local\Temp\cccMCOUz.o:window.cpp:(.text+0x37b): undefined reference to
SDL_GL_CreateContext’
C:\Users\ALEXAN~1\AppData\Local\Temp\cccMCOUz.o:window.cpp:(.text+0x392):
undefined reference toSDL_GL_SetSwapInterval' C:\Users\ALEXAN~1\AppData\Local\Temp\cccMCOUz.o:window.cpp:(.text+0x3a6): undefined reference to
SDL_GL_SetAttribute’
C:\Users\ALEXAN~1\AppData\Local\Temp\cccMCOUz.o:window.cpp:(.text+0x3ba):
undefined reference toSDL_GL_SetAttribute' C:\Users\ALEXAN~1\AppData\Local\Temp\cccMCOUz.o:window.cpp:(.text+0x3ce): undefined reference to
SDL_GL_SetAttribute’
C:\Users\ALEXAN~1\AppData\Local\Temp\cccMCOUz.o:window.cpp:(.text+0x3e2):
undefined reference toSDL_GL_SetAttribute' C:\Users\ALEXAN~1\AppData\Local\Temp\cccMCOUz.o:window.cpp:(.text+0x3f6): undefined reference to
SDL_GL_SetAttribute’
C:\Users\ALEXAN~1\AppData\Local\Temp\cccMCOUz.o:window.cpp:(.text+0x40a):
more undefined references toSDL_GL_SetAttribute' follow C:\Users\ALEXAN~1\AppData\Local\Temp\cccMCOUz.o:window.cpp:(.text+0x42e): undefined reference to
glClearColor at 16’
C:\Users\ALEXAN~1\AppData\Local\Temp\cccMCOUz.o:window.cpp:(.text+0x455):
undefined reference toglViewport at 16' C:\Users\ALEXAN~1\AppData\Local\Temp\cccMCOUz.o:window.cpp:(.text+0x464): undefined reference to
glMatrixMode at 4’
C:\Users\ALEXAN~1\AppData\Local\Temp\cccMCOUz.o:window.cpp:(.text+0x46a):
undefined reference toglLoadIdentity at 0' C:\Users\ALEXAN~1\AppData\Local\Temp\cccMCOUz.o:window.cpp:(.text+0x4af): undefined reference to
gluPerspective at 32’
C:\Users\ALEXAN~1\AppData\Local\Temp\cccMCOUz.o:window.cpp:(.text+0x4be):
undefined reference toglMatrixMode at 4' C:\Users\ALEXAN~1\AppData\Local\Temp\cccMCOUz.o:window.cpp:(.text+0x4c4): undefined reference to
glLoadIdentity at 0’
C:\Users\ALEXAN~1\AppData\Local\Temp\cccMCOUz.o:window.cpp:(.text+0x4d8):
undefined reference toglBlendFunc at 8' C:\Users\ALEXAN~1\AppData\Local\Temp\cccMCOUz.o:window.cpp:(.text+0x4e7): undefined reference to
glLineWidth at 4’
C:\Users\ALEXAN~1\AppData\Local\Temp\cccMCOUz.o:window.cpp:(.text+0x4f4):
undefined reference toglEnable at 4' C:\Users\ALEXAN~1\AppData\Local\Temp\cccMCOUz.o:window.cpp:(.text+0x501): undefined reference to
glEnable at 4’
C:\Users\ALEXAN~1\AppData\Local\Temp\cccMCOUz.o:window.cpp:(.text+0x50e):
undefined reference toglGetString at 4' C:\Users\ALEXAN~1\AppData\Local\Temp\cccMCOUz.o:window.cpp:(.text+0x51f): undefined reference to
glGetString at 4’
C:\Users\ALEXAN~1\AppData\Local\Temp\cccMCOUz.o:window.cpp:(.text+0x52e):
undefined reference toglGetString at 4' C:\Users\ALEXAN~1\AppData\Local\Temp\cccMCOUz.o:window.cpp:(.text+0x100): undefined reference to
SDL_GetWindowPosition’
C:\Users\ALEXAN~1\AppData\Local\Temp\cccMCOUz.o:window.cpp:(.text+0x116):
undefined reference toSDL_DestroyWindow' C:\Users\ALEXAN~1\AppData\Local\Temp\cccMCOUz.o:window.cpp:(.text+0x130): undefined reference to
SDL_GetWindowID’
C:\Users\ALEXAN~1\AppData\Local\Temp\cccMCOUz.o:window.cpp:(.text+0x140):
undefined reference toSDL_ShowWindow' C:\Users\ALEXAN~1\AppData\Local\Temp\cccMCOUz.o:window.cpp:(.text+0x150): undefined reference to
SDL_HideWindow’
C:\Users\ALEXAN~1\AppData\Local\Temp\cccMCOUz.o:window.cpp:(.text+0x1e5):
undefined reference toSDL_GetWindowPosition' C:\Users\ALEXAN~1\AppData\Local\Temp\cccMCOUz.o:window.cpp:(.text+0x1f8): undefined reference to
SDL_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