Alex Barry
2012-08-11 17:12:05 UTC
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++
$ mingw32-make -f Makefile.win32
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
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
$(CC) $(OTHERFLAGS) $(CFLAGS) $(LDFLAGS) $(SOURCES) -o $(EXECUTABLE)
rm -f $(EXECUTABLE)
clean: clean-executable
rebuild: clean all
The output I get, however, is quite bad:LDFLAGS=`sdl2-config --libs` -lSDL2_ttf -lopengl32 -lglu32
OTHERFLAGS=-static
SOURCES=application.cpp event.cpp exceptions.cpp thread.cpp window.cpp
EXECUTABLE=sdlui
$(CC) $(OTHERFLAGS) $(CFLAGS) $(LDFLAGS) $(SOURCES) -o $(EXECUTABLE)
rm -f $(EXECUTABLE)
clean: clean-executable
rebuild: clean all
$ 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
undefined reference to `SDL_main'
undefined reference to `SDL_PollEvent'
undefined reference to `SDL_PollEvent'
undefined reference to `SDL_Init'
undefined reference to `barrysoft::FontFactory::getInstance()'
undefined reference to `barrysoft::FontFactory::getInstance()'
undefined reference to `barrysoft::FontFactory::~FontFactory()'
undefined reference to `SDL_Quit'
undefined reference to `SDL_GetError'
undefined reference to `SDL_GetError'
undefined reference to `SDL_mutexP'
undefined reference to `SDL_CreateMutex'
undefined reference to `SDL_mutexP'
undefined reference to `SDL_mutexV'
undefined reference to `SDL_mutexP'
undefined reference to `SDL_mutexV'
undefined reference to `SDL_Delay'
undefined reference to `SDL_mutexV'
undefined reference to `SDL_mutexP'
undefined reference to `SDL_mutexV'
undefined reference to `SDL_mutexP'
undefined reference to `SDL_WaitThread'
undefined reference to `SDL_DestroyMutex'
undefined reference to `SDL_CreateMutex'
undefined reference to `SDL_CreateThread'
undefined reference to `SDL_mutexV'
undefined reference to `SDL_DestroyMutex'
undefined reference to `SDL_mutexP'
undefined reference to `SDL_mutexV'
undefined reference to `SDL_mutexV'
undefined reference to `SDL_CreateWindow'
undefined reference to `SDL_SetWindowSize'
undefined reference to `SDL_SetWindowPosition'
undefined reference to `SDL_GL_DeleteContext'
undefined reference to `SDL_GL_MakeCurrent'
undefined reference to `SDL_GL_CreateContext'
undefined reference to `SDL_GL_SetSwapInterval'
undefined reference to `SDL_GL_SetAttribute'
undefined reference to `SDL_GL_SetAttribute'
undefined reference to `SDL_GL_SetAttribute'
undefined reference to `SDL_GL_SetAttribute'
undefined reference to `SDL_GL_SetAttribute'
more undefined references to `SDL_GL_SetAttribute' follow
undefined reference to `SDL_GetWindowPosition'
undefined reference to `SDL_DestroyWindow'
undefined reference to `SDL_GetWindowID'
undefined reference to `SDL_ShowWindow'
undefined reference to `SDL_HideWindow'
undefined reference to `SDL_GetWindowPosition'
undefined reference to `SDL_GetWindowID'
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`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
undefined reference to `SDL_main'
undefined reference to `SDL_PollEvent'
undefined reference to `SDL_PollEvent'
undefined reference to `SDL_Init'
undefined reference to `barrysoft::FontFactory::getInstance()'
undefined reference to `barrysoft::FontFactory::getInstance()'
undefined reference to `barrysoft::FontFactory::~FontFactory()'
undefined reference to `SDL_Quit'
undefined reference to `SDL_GetError'
undefined reference to `SDL_GetError'
undefined reference to `SDL_mutexP'
undefined reference to `SDL_CreateMutex'
undefined reference to `SDL_mutexP'
undefined reference to `SDL_mutexV'
undefined reference to `SDL_mutexP'
undefined reference to `SDL_mutexV'
undefined reference to `SDL_Delay'
undefined reference to `SDL_mutexV'
undefined reference to `SDL_mutexP'
undefined reference to `SDL_mutexV'
undefined reference to `SDL_mutexP'
undefined reference to `SDL_WaitThread'
undefined reference to `SDL_DestroyMutex'
undefined reference to `SDL_CreateMutex'
undefined reference to `SDL_CreateThread'
undefined reference to `SDL_mutexV'
undefined reference to `SDL_DestroyMutex'
undefined reference to `SDL_mutexP'
undefined reference to `SDL_mutexV'
undefined reference to `SDL_mutexV'
undefined reference to `SDL_CreateWindow'
undefined reference to `SDL_SetWindowSize'
undefined reference to `SDL_SetWindowPosition'
undefined reference to `SDL_GL_DeleteContext'
undefined reference to `SDL_GL_MakeCurrent'
undefined reference to `SDL_GL_CreateContext'
undefined reference to `SDL_GL_SetSwapInterval'
undefined reference to `SDL_GL_SetAttribute'
undefined reference to `SDL_GL_SetAttribute'
undefined reference to `SDL_GL_SetAttribute'
undefined reference to `SDL_GL_SetAttribute'
undefined reference to `SDL_GL_SetAttribute'
more undefined references to `SDL_GL_SetAttribute' follow
undefined reference to `SDL_GetWindowPosition'
undefined reference to `SDL_DestroyWindow'
undefined reference to `SDL_GetWindowID'
undefined reference to `SDL_ShowWindow'
undefined reference to `SDL_HideWindow'
undefined reference to `SDL_GetWindowPosition'
undefined reference to `SDL_GetWindowID'
collect2: ld returned 1 exit status
mingw32-make: *** [all] Error 1
$ 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.-L/usr/local/lib -lmingw32 -lSDL2main -lSDL2 -mwindows
-I/usr/local/include/SDL2 -Dmain=SDL_main
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