2

So I am trying to get a basic sdl program to compile. I have been confronted with multiple different errors which I have resolved from being unable to find the libraries in question. This error however I have no idea how to fix. The bad realoc error in particular concerns me, though I assume it will go away once I figure out how to define the particular functions involved.

So Windows 7, 64bit using gcc.exe from mingw

I grabbed SDL2-devel-2.0.3-mingw.tar.gz from https://www.libsdl.org/download-2.0.php

I have a compile.bat file which I made myself.

D:
"D:\MinGW\bin\gcc.exe" sdlproto.c -o sdlproto.exe -ISDL2-2.0.3\x86_64-w64-mingw32\include\SDL2 -LSDL2-2.0.3\x86_64-w64-mingw32\lib -lSDL2 -lSDL2main
pause

So the Error Message

C:\Users\BREADP~1\AppData\Local\Temp\ccitXsxN.o:sdlproto.c:(.text+0xe): undefined reference to `SDL_Init'
C:\Users\BREADP~1\AppData\Local\Temp\ccitXsxN.o:sdlproto.c:(.text+0x13): undefined reference to `SDL_Quit'
d:/mingw/bin/../lib/gcc/mingw32/4.8.1/../../../../mingw32/bin/ld.exe: C:\Users\BREADP~1\AppData\Local\Temp\ccitXsxN.o: bad reloc address 0x20 in section `.eh_frame'
d:/mingw/bin/../lib/gcc/mingw32/4.8.1/../../../../mingw32/bin/ld.exe: final link failed: Invalid operationcollect2.exe: error: ld returned 1 exit status
  • Please ask a specific question. I am assuming you are wondering about the error message. What have you tried to fix it? – dub stylee Mar 03 '15 at 18:39
  • From your input I have included additional text to the original post. Apologies. – Bread Product Mar 03 '15 at 18:48
  • possible duplicate of [What is an undefined reference/unresolved external symbol error and how do I fix it?](http://stackoverflow.com/questions/12573816/what-is-an-undefined-reference-unresolved-external-symbol-error-and-how-do-i-fix) – genpfault Mar 03 '15 at 19:17

1 Answers1

1

I have found a solution. Step one was that I was accidentally using mingw32 on a 64 bit machine. Moving to mingw64 changed the error message to missing WinMain. Changing the starting function from main to WinMain allowed it to compile with no issues AND the following source code ran with no errors.

#include "SDL.h"

int WinMain(int argc, char *argv[])
{
SDL_Init(SDL_INIT_EVERYTHING);
SDL_Quit();
return 0;
} 

This solution screams wrong but it's functioning as far as I can tell.