NO

Author Topic: Setting Up SDL  (Read 3285 times)

PaulR

  • Guest
Setting Up SDL
« on: August 15, 2012, 11:17:30 AM »
I've been trying to set up SDL in a 'clean' way such that header files and libraries are kept separate from Pelles C files. This will enable both to be upgraded easily without causing problems.

This applies to version 7.0 of Pelles C and SDL 1.2.15.

Here's what I did:

  • Installed Pelles C 32 bit
  • Dowloaded SDL Development libraries for Win 32 (http://www.libsdl.org/release/SDL-devel-1.2.15-VC.zip) and extracted to C:\SDL-1.2.15
  • Dowloaded SDL source code and extracted to \temp then compiled \temp\src\main\win32\SDL_win32_main.c to target Win32 static library, file name SDLmain.lib. Put resulting SDLmain.lib in C:\SDL-1.2.15\lib\x86 overwriting original version
  • Created a new project with 32 bit console application as the target
  • In Project Options folders tab added C:\SDL-1.2.15\lib\x86 to list of Libraries search paths
  • In Project Options folders tab added C:\SDL-1.2.15\include to list of Includes search paths
  • In Project Options compiler tab checked 'Enable Microsoft Extensions'
  • In Project Options linker tab added SDL.lib and SDLmain.lib to list of Library and object files (contents now kernel32.lib advapi32.lib delayimp.lib SDLmain.lib SDL.lib)
  • Copied SDL.dll from C:\SDL-1.2.15\lib\x86 to project folder
  • Removed all other copies of SDL.dll from my computer
  • Added main.c to Project with code as follows:

Code: [Select]
#include <SDL.h>
int main( int argc, char* args[] ) {
//Start SDL
SDL_Init( SDL_INIT_EVERYTHING );
//Quit SDL
        SDL_Quit();
return 0;
}

Results of building:

Building main.obj.
Use <stdlib.h> instead of non-standard <malloc.h>
Building main.exe.
Done.

Just one warning which can be cured by a couple of simple edits if required (replacing malloc.h with stdlib.h), see  http://forum.pellesc.de/index.php?topic=2858.0

Paul

« Last Edit: August 17, 2012, 03:54:39 PM by PaulR »

Offline TimoVJL

  • Global Moderator
  • Member
  • *****
  • Posts: 1555
Re: Setting Up SDL
« Reply #1 on: August 15, 2012, 02:30:59 PM »
Remember to compile SDL_win32_main.c with PellesC to library SDLmain.lib .
Or use this one as attached.

Here is modified source for that: http://forum.pellesc.de/index.php?topic=3194.msg14341#msg14341
« Last Edit: August 15, 2012, 02:51:17 PM by timovjl »
May the source be with you

PaulR

  • Guest
Re: Setting Up SDL
« Reply #2 on: August 15, 2012, 02:47:27 PM »
 :-[ Doh! Thank you - that fixes it, I now have Pelles C with SDL without any mixing of files. First post edited to summarise the steps required should anyone else need a hand with this. :D

Paul


PaulR

  • Guest
Re: Setting Up SDL
« Reply #3 on: August 17, 2012, 11:21:05 AM »
I've created a thread that contains simple instructions and just the essential files to get SDL up and running for 32 bit Windows here:

http://forum.pellesc.de/index.php?topic=4707.0

No compilation is required, the necessary *.lib has already been compiled using Pelles C for you :D