examples: SDLexample: fix the WinMain issue using native means of SDL, libraries linkage fix, howto setup compile environment

git-svn-id: svn://ultimatepp.org/upp/trunk@3375 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
kohait 2011-04-26 20:50:26 +00:00
parent 16e6eaaab6
commit 4ea1099c33
4 changed files with 59 additions and 4 deletions

View file

@ -1,17 +1,22 @@
description "SDL demo example";
description "SDL demo example\377";
uses
Core;
library(MSC) "SDL SDLmain";
library(GCC WIN32) "SDL.dll SDLmain";
library(GCC WIN32 !SHARED) "SDL.dll SDLmain mingw32";
library(GCC WIN32 SHARED) "SDL SDLmain mingw32";
library(LINUX) "SDL SDLmain";
library(FREEBSD) "SDL SDLmain X11 Xext Xrandr Xrender vga vgl aa usbhid ncurses";
link(MSC DEBUG) /NODEFAULTLIB:msvcrt.lib;
file
compile.txt,
main.cpp;
mainconfig

View file

@ -0,0 +1,45 @@
SETUP SDL for Linux.
install the SDL 1.2.x package of your distro, dont forget to install the SDL-devel package for headers.
SETUP SDL for windows.
download binaries / prebuilt packages for msc and mingw
http://www.libsdl.org/download-1.2.php
http://www.libsdl.org/release/SDL-devel-1.2.14-VC8.zip
http://www.libsdl.org/release/SDL-devel-1.2.14-mingw32.tar.gz
unzip the stuff into 2 separate locations, e.g
C:\SDL-devel-1.2.14-VC8\SDL-1.2.14
C:\SDL-devel-1.2.14-mingw32\SDL-1.2.14
the buildmethods need to access those repspective folders
MSC buildmethod, add to
PATH: C:\SDL-devel-1.2.14-VC8\SDL-1.2.14\lib
INCLUDE: C:\SDL-devel-1.2.14-VC8\SDL-1.2.14\include
LIB: C:\SDL-devel-1.2.14-VC8\SDL-1.2.14\lib
MINGW/TDMGCC buildmethod, add to
PATH: C:\SDL-devel-1.2.14-mingw32\SDL-1.2.14\lib
C:\SDL-devel-1.2.14-mingw32\SDL-1.2.14\bin
INCLUDE: C:\SDL-devel-1.2.14-mingw32\SDL-1.2.14\include
LIB: C:\SDL-devel-1.2.14-mingw32\SDL-1.2.14\lib
C:\SDL-devel-1.2.14-mingw32\SDL-1.2.14\bin
the MSC libraries only come in shared linkage flavor, while the mingw flavor can be linked both shared and staticly.
the SDL.dll.a is needed for static lib and has got that weired name. who knows why. the SDL.dll comes in bin folder,
thats why double folder specification is needed fir MINGW build method
the WinMain@16 compile problem for mingw (google for it) makes the change of lib link order
obligatory, thats why mingw32 is specified explicitly last. this makes the WINAPI WinMain() { return main(); }
hack obsolete and enables the native usage of SDL means to handle entry point.
SDL redefines your own main to be SDL_main (see SDL.h), and provides own main. the signature is critical.
it must be
int main(int argc, char* argv[]);

4
examples/SDLExample/init Normal file
View file

@ -0,0 +1,4 @@
#ifndef _SDLExample_icpp_init_stub
#define _SDLExample_icpp_init_stub
#include "Core/init"
#endif

View file

@ -2,9 +2,10 @@
using namespace Upp;
#ifdef PLATFORM_WIN32
#ifdef COMPILER_MSC
#include <SDL.h>
#else
#endif
#ifdef COMPILER_GCC
#include <SDL/SDL.h>
#endif