NO

Author Topic: Graphics using SDL with Pelles C  (Read 5447 times)

goodwillhart

  • Guest
Graphics using SDL with Pelles C
« on: March 18, 2006, 07:05:29 AM »
Hi,

I'm about to start using the Simple Directmedia Layer (SDL) library to write some graphics programs with Pelles C. I'm also about to write a tutorial on how to do it, so even though I appear to have got it working, I want to check whether I have done it correctly.

Which of the following steps are NOT needed or wrong:

1) Put sdl.dll into the PellesC\bin directory.
2) Run polib.exe in the PellesC\bin directory:
polib sdl.dll /OUT:sdl.lib
3) Put sdl.lib into the PellesC\lib directory.
4) Put all the SDL include (.h) files into the PellesC\include directory
5) Create a new Win32 [.exe] project
6) Add sdl.lib to the list of libraries to be linked in the project/linker options of your project
7) Put sdl_win32_main.c in your project directory
8 ) Add sdl_win32_main.c to your project
9) Global replace alloca with _alloca in the sdl_win32_main.c file OR check the "Define compatibility names" option in the project/compiler options.
10) Write your SDL program, add it to your project, compile it and enjoy.

I've seen a couple of threads about SDL and no one seems to do all these things. Are some of them unnecessary, or did I miss something?

Bill Hart
http://www.friedspace.com/CProg.html

Ngan Lo

  • Guest
Graphics using SDL with Pelles C
« Reply #1 on: March 18, 2006, 08:08:08 AM »
http://smorgasbordet.com/phpBB2/viewtopic.php?t=562&highlight=sdl

have u checked the above thread ? the solution is make the sdlmain.lib using PellesC, but the thread was using SDL 1.2.8, dont know if newer version also work.

as i remember, it's no need to use polib to import the sdl.lib, just link the win32 build, just only need to rebuild sdlmain.lib. (hope this help b'cuz i'm not using SDL, just a little test a while ago...)

good luck.  :wink:

goodwillhart

  • Guest
SDL
« Reply #2 on: March 18, 2006, 09:11:44 PM »
Yes, I saw that thread. Certainly I'm linking in the SDL_win32_main.c, which I think corresponds to the SDLmain that you are talking about. However, according to some documentation I found on the web, this is not the same as the SDL.dll, which you need a .lib file for.

Certainly I can't do without either the SDL.dll file or the SDL.lib file (I tested it without each), so I think I need to make the SDL.lib file with POLIB. All the SDLmain.lib file does is call your main() from within a Windows program. It doesn't actually provide any of the functions of SDL itself, which are all in the SDL.dll file.

Perhaps you are right. SDL may have changed. But then again, perhaps there is something else I have missed. If anyone knows a simpler way to set up the latest version of SDL with Pelles C, please let me know.

Thanks.

Bill Hart.
http://www.friedspace.com/CProg.html

Ngan Lo

  • Guest
Graphics using SDL with Pelles C
« Reply #3 on: March 19, 2006, 09:58:21 AM »
i just have a quick test about SDL 1.2.9 & it's working here, here's my steps for setting up :
- download SDL source code & developer libraries from libsdl.org
- create a project (Win32 Static Library), name it "sdlmain"
- extract all source code files to project folder, add "SDL_win32_main.c" file into project, set _cdecl Call conv:, check Define compatibility names.
- build sdlmain.lib & copy to PellesC's lib folder.
- also copy sdl.lib, sdl.dll (& all include files, from SDL developer libraries) to PellesC's folder.

then i download a tutorial from http://lazyfooproductions.com/SDL_tutorials/lesson02/index.php

- create a new project (Win32 exe) for this tutorial
- copy lession02.cpp contents into a new main.c file (change string to char*)
- set _cdecl Call conv:, check Define compatibility names, add sdl.lib & sdlmain.lib in project option > linker
- build the project & run, it just work.

goodwillhart

  • Guest
Thanks
« Reply #4 on: March 22, 2006, 12:52:00 AM »
I didn't realise you could create a library this way. That is great. It saves explaining how to use POLIB.

I'll make sure I acknowledge you when I finish writing my tutorial.

Bill.