Windows 7 MinGW Link Error

I posted this on SDL forums, but it had errors, so I cancelled the pending
message to this mailing list and typed it in manually:–

When I try to compile a test SDL application in Eclipse with MinGW, I get
the following error when it tries to link:

g++ -LC:\SDL\lib -o test.exe main.o -lmingw32 -lSDLmain -lSDL
C:\SDL\lib/libSDLmain.a(SDL_win32_main.o): In function console_main': /Users/hercules/trunk/SDL-1.2/./src/main/win32/SDL_win32_main.c:315: undefined reference toSDL_main’
collect2: ld returned 1 exit status

I’ve tried the command on a command link and get the exact same output. All
of the libraries and header files are properly include (as far as I can
tell). Also, the DLL is in the Debug folder of the Eclipse project. What’s
causing this?

I’m running Windows 7 Home Edition 64-bit, the latest MinGW release (as of
today), SDL 1.2.14, and Eclipse 4.1.

Any help is appreciated. :wink:

Eric

/Users/hercules/trunk/SDL-1.2/./src/main/win32/SDL_win32_main.c:315:
undefined reference to `SDL_main’

Make sure SDL.h is #included in whatever file has your main()
function…it’ll #define “main” to be “SDL_main” and then your link will
succeed.

If you have your own WinMain(), don’t link against SDLmain. The reason
we do this is so every platform just uses a main() function and SDL
hides the differences.

–ryan.

Already done, as seen here:

Code:
#include <SDL/SDL.h>

int main()
{
SDL_Init(SDL_INIT_EVERYTHING);

SDL_Quit();

return 0;

}

int main()

You got bitten by C++ function overloading.

Change that line to:

int main(int argc, char *argv[])

–ryan.

It works! Thanks! :slight_smile:

I have something strange happening too, Can’t get still sdl to work in Eclipse kepler, cloud someone help me via teamviewer?

This forum is not a place for IT support, if you want help just explain
what is your problem or error and people will try to give you advice. On
the other hand i have not tried eclipse and mingw and sdl, are you on
Windows?, I only use Codeblocks and VSEE and they are similar in the way to
linking to libraries, i imagine eclipse is not so different.

2014-06-03 9:45 GMT-06:00 Murda <Murda.ESC at hotmail.com>:> I have something strange happening too, Can’t get still sdl to work in

Eclipse kepler, cloud someone help me via teamviewer?


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


Javier Flores

Yes I’m on windows, I have tried all kind of tutorials but it still return error when i try to compile about not finding sdl2 files, however they were linked, maybe anybody knows where i can find proper tutorial?

Is your main int main( int argc, char* args[] ) ?

Murda wrote:> Yes I’m on windows, I have tried all kind of tutorials but it still return error when i try to compile about not finding sdl2 files, however they were linked, maybe anybody knows where i can find proper tutorial?

http://lazyfoo.net/SDL_tutorials/lesson01/windows/eclipse/index.php

Murda wrote:> I have something strange happening too, Can’t get still sdl to work in Eclipse kepler, cloud someone help me via teamviewer?

I was with the same kind of problem on windows, the compiler just doesn’t compile the code(I don’t remember the error) that I did on Linux with gcc. The int main was wrong, so I think that this should work: int main(int argc, char* argv[])From: alex-rou@hotmail.com
Date: Sun, 8 Jun 2014 12:11:45 +0000
To: sdl at lists.libsdl.org
Subject: Re: [SDL] Windows 7 MinGW Link Error

http://lazyfoo.net/SDL_tutorials/lesson01/windows/eclipse/index.php












Murda wrote:


I have something strange happening too, Can't get still sdl to work in Eclipse kepler, cloud someone help me via teamviewer?

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