Thread: SDL project setup

  1. #1
    Registered User rogster001's Avatar
    Join Date
    Aug 2006
    Location
    Liverpool UK
    Posts
    1,472

    SDL project setup

    GRRRR! i have tried installing the SDL for dev cpp and had no luck so now i have followed the tutorial for the code blocks and sdl install found on these pages. The problem is when trying to create the SDL project first it tells me the global variable type 'SDL' is not recognised, but then i can ignore that step and go on to a step where it tells me i have to tell code blocks where 'SDL' is located, the tip it gives is the location of the folder that SDL was unzipped to, the root folder containing include and lib,
    well i have pointed it at this folder and also tried the SDL folder in my code blocks directory and either way all i get is it cant find the include folder or it can't find the SDL.h file in the folder(despite the fact the damn thing is in there) and the wizard can't continue

    any advice gratefully accepted...

  2. #2
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    Is there any specific error you're getting? Like it saying SDL undeclared or stuff?
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  3. #3
    Registered User rogster001's Avatar
    Join Date
    Aug 2006
    Location
    Liverpool UK
    Posts
    1,472

    Exclamation error message >

    "the path you entered seemed valid but this wizard can't locate the following SDL's include file 'SDL.h' in it"

    This error suggests that i actually have the wizard pointing at the right folder becuase it is no longer throwing same error but with > 'wizard can't locate the include directory'
    (instead of the header file)

    so its looking in the right place but can't see the SDL.h it seems.

  4. #4
    Registered User
    Join Date
    Dec 2006
    Location
    Canada
    Posts
    3,229
    Well then, can you find SDL.h in there?

  5. #5
    Registered User rogster001's Avatar
    Join Date
    Aug 2006
    Location
    Liverpool UK
    Posts
    1,472
    yes, as i said, the file is there, all present and correct, most annoying, never had any luck with this SDL, maybe uninstall code blocks and SDL and go again.

  6. #6
    Registered User
    Join Date
    Dec 2006
    Location
    Canada
    Posts
    3,229
    Try including <SDL/SDL.h> instead.

    The recommended way is to use sdl-config to generate an include path for GCC.

  7. #7
    Registered User rogster001's Avatar
    Join Date
    Aug 2006
    Location
    Liverpool UK
    Posts
    1,472
    thanks will give it a go!

  8. #8
    Frequently Quite Prolix dwks's Avatar
    Join Date
    Apr 2005
    Location
    Canada
    Posts
    8,057
    If the wizard isn't working out for you, you should be able to set it up manually. You'll need to do three things:
    • Add the include directory to the project's custom include directories. It's best if you add the directory which contains SDL.h directly, so you can #include "SDL.h" instead of SDL/SDL.h.
    • Add the SDL library directory to the linker path, the directory which contains SDL.lib.
    • Link with SDL.lib and SDLmain.lib.

    Actually, there's a fourth thing you need to do: SDL.dll needs to be accessible before your compiled program will run. You can put it in the current working directory, or in c:\windows\system32.

    Also try this tutorial: Lazy Foo' Productions
    dwk

    Seek and ye shall find. quaere et invenies.

    "Simplicity does not precede complexity, but follows it." -- Alan Perlis
    "Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
    "The only real mistake is the one from which we learn nothing." -- John Powell


    Other boards: DaniWeb, TPS
    Unofficial Wiki FAQ: cpwiki.sf.net

    My website: http://dwks.theprogrammingsite.com/
    Projects: codeform, xuni, atlantis, nort, etc.

  9. #9
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    Quote Originally Posted by dwks View Post
    #include "SDL.h" instead of SDL/SDL.h.
    Or...
    #include <SDL.h>
    ...since it's in an include path.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  10. #10
    Frequently Quite Prolix dwks's Avatar
    Join Date
    Apr 2005
    Location
    Canada
    Posts
    8,057
    Yes, indeed. I prefer "SDL.h" with double quotes, though; that way, the user can easily use a different version of the SDL if they choose by including it in a local directory. (Come to think of it, you could probably override the standard inclusion path and do it that way.)

    Anyway, I'm sure there are other reasons: Simple DirectMedia Layer
    Q: Do I #include <SDL.h> or <SDL/SDL.h>?
    A: The most portable way to include SDL headers is to use quotes around the header name:

    #include "SDL.h"
    dwk

    Seek and ye shall find. quaere et invenies.

    "Simplicity does not precede complexity, but follows it." -- Alan Perlis
    "Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
    "The only real mistake is the one from which we learn nothing." -- John Powell


    Other boards: DaniWeb, TPS
    Unofficial Wiki FAQ: cpwiki.sf.net

    My website: http://dwks.theprogrammingsite.com/
    Projects: codeform, xuni, atlantis, nort, etc.

  11. #11
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    Interesting. Why would they say double quotes are more portable?
    "" vs <> really have little to do with portability. Putting the files in the project folder or some standard include path might have more effect, though.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  12. #12
    Frequently Quite Prolix dwks's Avatar
    Join Date
    Apr 2005
    Location
    Canada
    Posts
    8,057
    Best I could find: Doomworld Forums - Eternity buildable using Dev-C++
    The instructions on that page assume that people are using #include <SDL.h> instead of #include "SDL.h" -- the former is actually incorrect, since SDL is not part of any standard library -- this is why you need to take the extra step to point the compiler to wherever you put the SDL/SDL_mixer headers.
    Also semi-relevant:
    [vorbis-dev] #include scheme in vorbis project

    The only thing I can think of is that there are some compilers for which -I equivalent options don't add to the include path for angle-bracketed #includes. I don't know of any such compilers, of course. Or perhaps the writers of the SDL documentation don't know as much about C and C++ as they would profess to . . . .
    dwk

    Seek and ye shall find. quaere et invenies.

    "Simplicity does not precede complexity, but follows it." -- Alan Perlis
    "Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
    "The only real mistake is the one from which we learn nothing." -- John Powell


    Other boards: DaniWeb, TPS
    Unofficial Wiki FAQ: cpwiki.sf.net

    My website: http://dwks.theprogrammingsite.com/
    Projects: codeform, xuni, atlantis, nort, etc.

  13. #13
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    >>the former is actually incorrect, since SDL is not part of any standard library
    Say what? <> has nothing to do with standard libraries and everything to do with how the compiler (or pre-processor, really) searches paths for the headers to include.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  14. #14
    Frequently Quite Prolix dwks's Avatar
    Join Date
    Apr 2005
    Location
    Canada
    Posts
    8,057
    Exactly. That's why I'm thinking that the documentation may be wrong. But it's too late anyway: I use "SDL.h" with double quotes by habit already.
    dwk

    Seek and ye shall find. quaere et invenies.

    "Simplicity does not precede complexity, but follows it." -- Alan Perlis
    "Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
    "The only real mistake is the one from which we learn nothing." -- John Powell


    Other boards: DaniWeb, TPS
    Unofficial Wiki FAQ: cpwiki.sf.net

    My website: http://dwks.theprogrammingsite.com/
    Projects: codeform, xuni, atlantis, nort, etc.

  15. #15
    Registered User
    Join Date
    Dec 2006
    Location
    Canada
    Posts
    3,229
    They recommend using sdl-config to add the SDL directory to include path.

    Code:
    cyberfish@cyberfish-laptop:~$ sdl-config --cflags
    -I/usr/include/SDL -D_GNU_SOURCE=1 -D_REENTRANT
    cyberfish@cyberfish-laptop:~$ sdl-config --libs
    -L/usr/lib -lSDL
    Code:
    gcc asdf.c `sdl-config --cflags` `sdl-config --libs`...

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. setup project in msvc2005
    By sgh in forum A Brief History of Cprogramming.com
    Replies: 0
    Last Post: 04-30-2008, 08:22 AM
  2. Problem about making setup project
    By sgh in forum Windows Programming
    Replies: 0
    Last Post: 04-30-2008, 03:09 AM
  3. Problems compiling this SDL app
    By Rider in forum C++ Programming
    Replies: 3
    Last Post: 03-27-2007, 12:22 PM
  4. MFC in an empty project
    By cunnus88 in forum Windows Programming
    Replies: 0
    Last Post: 10-09-2005, 09:19 AM
  5. Game Independent Anti-cheat Project Needs Programmers
    By GIA Project Lea in forum Projects and Job Recruitment
    Replies: 3
    Last Post: 09-15-2005, 07:41 PM