SDL under windows

Started by
3 comments, last by Greg K 20 years, 1 month ago
I am using SDL under windows after using it (successfully) under linux. I am trying to port a program to windows. When I try to compile my code everything compiles fine and then I get a linker error saying: [Linker error] undefined reference to `WinMain@16'' I am using Dev-C++, Mingw32, SDL1.2. The project options in Dev-C++ say Win32 Console. Any help would be appreciated. -Greg
Advertisement
Just make the project a regular Win32 application, and it should work.

~nz

// Website // Google // GameDev // NeHe // MSDN // OpenGL Extensions //
~neoztar "Any lock can be picked with a big enough hammer"my website | opengl extensions | try here firstguru of the week | msdn library | c++ faq lite
Do I have to? Can I leave it as a console app? It says somewhere in the sdl doc that you should use a console app and let SDL do it''s init in WinMain that it defines itself. Also, what is the #define for windows? WIN32? _WIN32?
Yes, keep your main() function. As you said, SDL has its own WinMain() that calls your main(). The #define for windows is WIN32.

~nz

// Website // Google // GameDev // NeHe // MSDN // OpenGL Extensions //
~neoztar "Any lock can be picked with a big enough hammer"my website | opengl extensions | try here firstguru of the week | msdn library | c++ faq lite
This is covered in the SDL Windows FAQ at www.libsdl.org.

Q: I get "Undefined reference to ''WinMain@16''"
A: Under Visual C++, you need to link with SDLmain.lib. Under the gcc build environments including Dev-C++, you need to link with the output of "sdl-config --libs", which is usually: -lmingw32 -lSDLmain -lSDL -mwindows

This topic is closed to new replies.

Advertisement