The Importance of Arguments

This morning, I committed a new revision to my work-in-progress game, blockling. Though I use Linux, I always compile a Windows binary so n00bs can play it too. Ain’t I nice?

This time, however, I got an error:

/opt/mingw/usr/i686-pc-mingw32/lib/libSDLmain.a(SDL_win32_main.o): In function `console_main':
/opt/mingw/tmp-sdl/SDL-1.2.14/./src/main/win32/SDL_win32_main.c:315: undefined reference to `_SDL_main' collect2: ld returned 1 exit status

I was completely confused. I had not changed the compilation script, yet it suddenly no longer worked. And I had no reason to suspect my game’s code, since it was compiling perfectly on Linux.

It was at this point that irrational fears began to dance through my head. “Oh no! My mingw cross-compiling environment must have gotten corrupted…somehow!” I thought to myself.

It wasn’t until I had spent over an hour recompiling mingw’s version of gcc and SDL, rearranging compiler flags, and Googling to no avail, that I finally resorted to inspecting my own code.

The first thing I noticed was this:

// int main(int argc, char** argv) {
int main() {

I had grown tired of seeing compiler warnings informing me that I hadn’t used those two variables, so a few days ago I had decided to simply comment that part out for now. And, like I said, it had been working perfectly on Linux.

But apparently SDL on Windows requires the use of those argument parameters. As soon as I put them back, it compiled perfectly.

Yeeaah.

Yet another reason why I don’t use Windows…