Error compiling Sdl under windows

I’m developing with SDL and OpenGL under Linux most of the time, but I like my programs to be compatible with windows as well. As of now, the only difference between the code is the start of the main function. “main” is great for Linux, but wasnt working for me under Windows. Adding:
#ifdef WIN32
#undef WinMain
#undef main
#endif
was working great, and I could use “main” as the entry point of my program. However, as I kept making changes and adding code, the method above has stopped working. The thing is, when I try compiling my old code ( before making the changes) still works. Could you please point me to an appropriate guide or something???

PS1. Note that 'Im using sdl 1.2 with codeblocks under windows 7 32bit. Im linking with:
-lSDL -lSDLmain -lOpenGL32 -lGlu32 -lmingw32 -mwindows

PS2. is it possible to build SDL2 using codeblocks under win7?===============================================
Dancing to Gangnam Style burns 500 calories, as well as 3000 years of human progress in music

The main hack you use should not be necessary. That’s the purpose of the
SDLmain library (to let you use a conforming “int main(int, char**)” on all
platforms). I work on Linux and Windows and I’ve never had a problem with
it. What errors do you have without the #ifdef WIN32 block?

Yes, it is possible to build SDL2 using Code::Blocks under Windows 7. Use
Cmake to generate a Code::Blocks project file (which will use Make to
control the build anyhow).

Jonny DOn Mon, Feb 25, 2013 at 4:13 PM, wrote:

I’m developing with SDL and OpenGL under Linux most of the time, but I
like my programs to be compatible with windows as well. As of now, the only
difference between the code is the start of the main function. “main” is
great for Linux, but wasnt working for me under Windows. Adding:
#ifdef WIN32
#undef WinMain
#undef main
#endif
was working great, and I could use “main” as the entry point of my
program. However, as I kept making changes and adding code, the method
above has stopped working. The thing is, when I try compiling my old code (
before making the changes) still works. Could you please point me to an
appropriate guide or something???

PS1. Note that 'Im using sdl 1.2 with codeblocks under windows 7 32bit. Im
linking with:
-lSDL -lSDLmain -lOpenGL32 -lGlu32 -lmingw32 -mwindows

PS2. is it possible to build SDL2 using codeblocks under win7?

Dancing to Gangnam Style burns 500 calories, as well as 3000 years of
human progress in music


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

Make sure to update MinGW when you use Code::Blocks.

For the record, if you don’t want to use SDL_main (can happen if your
prototype differs), just don’t include the SDL_main library and
#undefine main. On MinGW this should work just fine, because MinGW can
use main as an entry point even for GUI programs. On other toolchains
you have to use SDL_main if you don’t want a console, though…

And yes, I’m 100% sure it should work, when Sam Lantinga made that SDL
build I needed at last moment he didn’t include SDL_main ^_^; (I
suppose he thought the original SDL_main I had built should have
worked… didn’t realize it back then, honestly)

2013/2/25, Jonathan Dearborn :> The main hack you use should not be necessary. That’s the purpose of the

SDLmain library (to let you use a conforming “int main(int, char**)” on all
platforms). I work on Linux and Windows and I’ve never had a problem with
it. What errors do you have without the #ifdef WIN32 block?

Yes, it is possible to build SDL2 using Code::Blocks under Windows 7. Use
Cmake to generate a Code::Blocks project file (which will use Make to
control the build anyhow).

Jonny D

On Mon, Feb 25, 2013 at 4:13 PM, wrote:

I’m developing with SDL and OpenGL under Linux most of the time, but I
like my programs to be compatible with windows as well. As of now, the
only
difference between the code is the start of the main function. “main” is
great for Linux, but wasnt working for me under Windows. Adding:
#ifdef WIN32
#undef WinMain
#undef main
#endif
was working great, and I could use “main” as the entry point of my
program. However, as I kept making changes and adding code, the method
above has stopped working. The thing is, when I try compiling my old code
(
before making the changes) still works. Could you please point me to an
appropriate guide or something???

PS1. Note that 'Im using sdl 1.2 with codeblocks under windows 7 32bit.
Im
linking with:
-lSDL -lSDLmain -lOpenGL32 -lGlu32 -lmingw32 -mwindows

PS2. is it possible to build SDL2 using codeblocks under win7?

Dancing to Gangnam Style burns 500 calories, as well as 3000 years of
human progress in music


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