Jump to content
  • Advertisement
Sign in to follow this  
CaptNeo

Eclipse, Mingw & SDL with Windows

This topic is 3669 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello, up to now I've been working with VS, but got employed last week to work on a Mac-Project. Because I don't know better, I decided to set up a C++ environment with eclipse, so that I can work with one IDE at work and at home without having to convert Project-Formats between VS and X Code. On Windows however I can't get the simplest SDL/OpenGL example compiled (which runs fine with VS 2008), because the linker tells me: C:\Programme\MinGW\lib/libmingw32.a(main.o):main.c:(.text+0x104): undefined reference to `WinMain@16' A quick and dirty diagnosis: As far as I could find out on the Internet this has to do with the Project not being pure and proper Win32, meaning the compiler tries to create a console application. Sadly the Project creation dialog does not give me any options to influence this like in VS. I also been through the whole project settings dialogs and could not find anything that worked. Anyone familiar with eclipse with the mingw g++ compiler and what project settings checkbox/compiler parameter to set in order to get it right? Thx! CaptNeo

Share this post


Link to post
Share on other sites
Advertisement
You also have to use -lmingw32 as a linker flag to tell the linker to link to the mingw32 library. The order in which you link the libraries is important. This particular library has to be linked before the SDL libraries.

If you want a windows application without the console window you may also have to add -mwindows to the linker flags.

Share this post


Link to post
Share on other sites
Thx, I've tried it. The following is my console output:

**** Build of configuration Debug for project opengl_sdl2 ****

**** Internal Builder is used for build ****
g++ -IC:\Programme\MinGW\include\Development -O0 -g3 -Wall -c -fmessage-length=0 -osrc\opengl_sdl2.o ..\src\opengl_sdl2.cpp
g++ -LC:\Programme\MinGW\lib\Development\SDL -LC:\Programme\MinGW\lib -mwindows -oopengl_sdl2.exe src\opengl_sdl2.o -lmingw32 -lsdl -lopengl32 -lglu32
C:\Programme\MinGW\lib/libmingw32.a(main.o):main.c:(.text+0x104): undefined reference to `WinMain@16'
collect2: ld returned 1 exit status
Build error occurred, build is stopped
Time consumed: 625 ms.

Share this post


Link to post
Share on other sites
Update: I've found, that sdlmain was missing. To make sure, I did not forget anything else, I've reshuffled the libs to confirm with an old VS project (should have done so in the first place for sure, sorry). So I get another error, which seems to be SDL specific:


**** Build of configuration Debug for project opengl_sdl2 ****

**** Internal Builder is used for build ****
g++ -LC:\Programme\MinGW\lib\Development\SDL -LC:\Programme\MinGW\lib -oopengl_sdl2.exe src\opengl_sdl2.o -lmingw32 -lopengl32 -lglu32 -lsdlmain -lsdl
C:\Programme\MinGW\lib\Development\SDL/libsdlmain.a(SDL_win32_main.o): In function `console_main':
/Users/hercules/trunk/SDL-1.2/./src/main/win32/SDL_win32_main.c:246: undefined reference to `SDL_main'
collect2: ld returned 1 exit status
Build error occurred, build is stopped
Time consumed: 235 ms.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!