The SDL forums have moved to discourse.libsdl.org.
This is just a read-only archive of the previous forums, to keep old links working.


SDL Forum Index
SDL
Simple Directmedia Layer Forums
#include "SDL/SDL.h" Vs. #include "SDL.h"
JeZ-l-Lee


Joined: 20 Sep 2009
Posts: 572
Location: Long Island, New York, United States, Earth
#include "SDL/SDL.h" Vs. #include "SDL.h" ???


Hi,

I use SDL to design cross-platform video games.

Which is the correct method to include SDL in my sources?
#include "SDL/SDL.h"
OR
#include "SDL.h"

On Linux it seems to be: #include "SDL/SDL.h"
and
on Windows it seems to be: #include "SDL.h"

Just trying to have 1 code base for all platforms.
My current (ugly) solution is the following:
//------------------------------------------------------------------------------
#ifdef WIN32
#include "SDL.h"
#include "SDL_image.h"
#include "SDL_ttf.h"
#include "SDL_opengl.h"
#else
#include "SDL/SDL.h"
#include "SDL/SDL_image.h"
#include "SDL/SDL_ttf.h"
#include "SDL/SDL_opengl.h"
#endif
//------------------------------------------------------------------------------

Anyone have an ideas about this?
Thanks...


JeZ+Lee

www.SilentHeroProductions.com

_______________________________________________
SDL mailing list

http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
#include "SDL/SDL.h" Vs. #include "SDL.h"
Alberto Luaces
Guest

Jesse Palser writes:


[...]

Quote:
On Linux it seems to be: #include "SDL/SDL.h"

No. "sdl-config --cflags" outputs -I/usr/include/SDL (among other
things), so the code should read also #include "SDL.h".

--
Alberto
_______________________________________________
SDL mailing list

http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
#include "SDL/SDL.h" Vs. #include "SDL.h"
Jonny D


Joined: 12 Sep 2009
Posts: 932
It is recommended to use "SDL.h" on every platform.  Use compiler options or project options (depending on your IDE) to add the .../include/SDL path to your compiler search directories.  For gcc, this is something like -I/usr/include/SDL.  This is what I do, but it's even better to use `sdl-config --cflags` (backticks necessary) and use `sdl-config --libs` as a linker option.

Jonny D


On Wed, Feb 17, 2010 at 7:58 AM, Jesse Palser wrote:
Quote:
#include "SDL/SDL.h" Vs. #include "SDL.h" ???


Hi,

I use SDL to design cross-platform video games.

Which is the correct method to include SDL in my sources?
#include "SDL/SDL.h"
OR
#include "SDL.h"

On Linux it seems to be: #include "SDL/SDL.h"
and
on Windows it seems to be: #include "SDL.h"

Just trying to have 1 code base for all platforms.
My current (ugly) solution is the following:
//------------------------------------------------------------------------------
#ifdef WIN32
 #include "SDL.h"
 #include "SDL_image.h"
 #include "SDL_ttf.h"
 #include "SDL_opengl.h"
#else
 #include "SDL/SDL.h"
 #include "SDL/SDL_image.h"
 #include "SDL/SDL_ttf.h"
 #include "SDL/SDL_opengl.h"
#endif
//------------------------------------------------------------------------------

Anyone have an ideas about this?
Thanks...


JeZ+Lee

www.SilentHeroProductions.com

_______________________________________________
SDL mailing list

http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
#include "SDL/SDL.h" Vs. #include "SDL.h"
Bill Kendrick
Guest

On Wed, Feb 17, 2010 at 08:07:51AM -0500, Jonathan Dearborn wrote:
Quote:
It is recommended to use "SDL.h" on every platform. *Use compiler options
or project options (depending on your IDE) to add the .../include/SDL path
to your compiler search directories. *For gcc, this is something like
-I/usr/include/SDL. *This is what I do, but it's even better to use
`sdl-config --cflags` (backticks necessary) and use `sdl-config --libs` as
a linker option.

Backticks when calling from a shell, but in a Makefile you can (and I think
should?) do it as, e.g.:

SDL_CFLAGS=$(shell sdl-config --cflags)
SDL_LIBS=$(shell sdl-config --libs)

Just mentioning...

-bill!
_______________________________________________
SDL mailing list

http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
#include "SDL/SDL.h" Vs. #include "SDL.h"
Alberto Luaces
Guest

Bill Kendrick writes:

Quote:
On Wed, Feb 17, 2010 at 08:07:51AM -0500, Jonathan Dearborn wrote:
Quote:
It is recommended to use "SDL.h" on every platform. *Use compiler options
or project options (depending on your IDE) to add the .../include/SDL path
to your compiler search directories. *For gcc, this is something like
-I/usr/include/SDL. *This is what I do, but it's even better to use
`sdl-config --cflags` (backticks necessary) and use `sdl-config --libs` as
a linker option.

Backticks when calling from a shell, but in a Makefile you can (and I think
should?) do it as, e.g.:

SDL_CFLAGS=$(shell sdl-config --cflags)
SDL_LIBS=$(shell sdl-config --libs)

Just mentioning...

In addition, in bash shell at least, you can use $() instead of the backticks:

$(sdl-config --cflags)
$(sdl-config --libs)

--
Alberto
_______________________________________________
SDL mailing list

http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
Keybounce


Joined: 05 Jul 2010
Posts: 3
Bumpy.

On the Mac, 10.5.8, ppc, I cannot find "sdl-config" in the official distribution of SDL.
Specifying -FSDL to the compiler is not enough to let it find the SDL framework.

Code:
Kleiman-ibook:23 michael$ ls /Library/Frameworks/
total 0
0 Adobe AIR.framework/         0 SDL_ttf.framework/
0 HPDeviceModel.framework/      0 SFML.framework/
0 HPPml.framework/         0 WOComponentElements.framework/
0 HPSMART.framework/         0 WOComponentExamples.framework/
0 HPServicesInterface.framework/   0 WOExamplesHarness.framework/
0 HPSmartPrint.framework/      0 WOSessionStoreExample.framework/
0 JavaBusinessLogic.framework/      0 iMoviePluginAPI.framework/
0 JavaMonitorSupport.framework/      0 sfml-audio.framework/
0 JavaRealEstate.framework/      0 sfml-graphics.framework/
0 PetStoreWOModel.framework/      0 sfml-network.framework/
0 SDL.framework/         0 sfml-system.framework/
0 SDL_image.framework/         0 sfml-window.framework/
0 SDL_mixer.framework/         0 sndfile.framework/
0 SDL_net.framework/
Kleiman-ibook:23 michael$ make
 * [UFO] src/client/cl_console.c
In file included from src/client/client.h:32,
                 from src/client/cl_console.c:30:
src/client/cl_renderer.h:34:17: error: SDL.h: No such file or directory

Code:
Kleiman-ibook:23 michael$ egrep CFLAG Makefile
CFLAGS= -I/opt/local/include -arch i386 -arch ppc
SDL_CFLAGS=-FSDL

Naturally, the <SDL/SDL.h> version works, but apparently that's a no-no (odd, as lots of packages seem to like being packaged inside a directory). Do I really need to add 5 -I statements for the 5 frameworks for SDL to work?

Also: Should the include statement be

#include "SDL.h"
or
#include <SDL.h>

Somehow, I thought that quotes were for your local project includes and the angle brackets for system includes.
#include "SDL/SDL.h" Vs. #include "SDL.h&
Eric Wing
Guest

On 8/4/10, Keybounce wrote:
Quote:
Bumpy.

On the Mac, 10.5.8, ppc, I cannot find "sdl-config" in the official
distribution of SDL.
Specifying -FSDL to the compiler is not enough to let it find the SDL
framework.


Code:
Kleiman-ibook:23 michael$ ls /Library/Frameworks/
total 0
0 Adobe AIR.framework/ 0 SDL_ttf.framework/
0 HPDeviceModel.framework/ 0 SFML.framework/
0 HPPml.framework/ 0 WOComponentElements.framework/
0 HPSMART.framework/ 0 WOComponentExamples.framework/
0 HPServicesInterface.framework/ 0 WOExamplesHarness.framework/
0 HPSmartPrint.framework/ 0 WOSessionStoreExample.framework/
0 JavaBusinessLogic.framework/ 0 iMoviePluginAPI.framework/
0 JavaMonitorSupport.framework/ 0 sfml-audio.framework/
0 JavaRealEstate.framework/ 0 sfml-graphics.framework/
0 PetStoreWOModel.framework/ 0 sfml-network.framework/
0 SDL.framework/ 0 sfml-system.framework/
0 SDL_image.framework/ 0 sfml-window.framework/
0 SDL_mixer.framework/ 0 sndfile.framework/
0 SDL_net.framework/
Kleiman-ibook:23 michael$ make
* [UFO] src/client/cl_console.c
In file included from src/client/client.h:32,
from src/client/cl_console.c:30:
src/client/cl_renderer.h:34:17: error: SDL.h: No such file or directory



Code:
Kleiman-ibook:23 michael$ egrep CFLAG Makefile
CFLAGS= -I/opt/local/include -arch i386 -arch ppc
SDL_CFLAGS=-FSDL



Naturally, the <SDL/SDL.h> version works, but apparently that's a no-no
(odd, as lots of packages seem to like being packaged inside a directory).
Do I really need to add 5 -I statements for the 5 frameworks for SDL to
work?

Also: Should the include statement be

#include "SDL.h"
or
#include <SDL.h>


#include <SDL/SDL.h> with work for your SDL Framework on OS X, but
then you would need to do:
#include <SDL_image/SDL_image.h>
#include <SDL_mixer/SDL_mixer.h>
etc.

For frameworks, the "path" is actually the framework name.

#include "SDL.h" is recommended for maximum code portability. Some
distributions don't always put things in a directory called "SDL".
Haven't verified in awhile, but once upon a time, FreeBSD put
everything in a directory called SDL11 (even though it was 1.2). And
obviously, OS X frameworks are going to have issues.

So yes, you will need to add a long string of -I statements if you
don't do the #include <SDL_image/SDL_image.h> stuff. I don't think
you'll need the -F flags though since your frameworks are in standard
locations and the linker will find these correctly/automatically.

Some systems have special or different search paths for angle brackets
than quotes. Generally speaking, quotes are better for things that
aren't in these special compiler paths.

-Eric
_______________________________________________
SDL mailing list

http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
#include "SDL/SDL.h" Vs. #include "SDL.h&
Donny Viszneki
Guest

I solved this problem two ways in my days of Mac OS X developing before Apple stabbed the FOSS community in the back :(

Solution A) Create your own sdl-config. It's really simple.

Solution B) Write a little more code to include the necessary headers. Here's how I accomplished that:

#ifdef APPLE
#  include <SDL/SDL.h>
#  include <OpenGL/GL.h>
#else
#  include <SDL.h>
#  include <GL/gl.h>
#endif

Of course that solution is just from memory of many years ago, so it has a few rough edges. When you or someone else tries to build your package on another system, it quickly becomes apparent what the problem is and a fix is usually easy to implement, so the absence of a real standard portable one-liner isn't that critical :)

On Wed, Aug 4, 2010 at 12:18 PM, Keybounce wrote:
Quote:
Bumpy.

On the Mac, 10.5.8, ppc, I cannot find "sdl-config" in the official distribution of SDL.
Specifying -FSDL to the compiler is not enough to let it find the SDL framework.

Code: Kleiman-ibook:23 michael$ ls /Library/Frameworks/
total 0
0 Adobe AIR.framework/         0 SDL_ttf.framework/
0 HPDeviceModel.framework/      0 SFML.framework/
0 HPPml.framework/         0 WOComponentElements.framework/
0 HPSMART.framework/         0 WOComponentExamples.framework/
0 HPServicesInterface.framework/   0 WOExamplesHarness.framework/
0 HPSmartPrint.framework/      0 WOSessionStoreExample.framework/
0 JavaBusinessLogic.framework/      0 iMoviePluginAPI.framework/
0 JavaMonitorSupport.framework/      0 sfml-audio.framework/
0 JavaRealEstate.framework/      0 sfml-graphics.framework/
0 PetStoreWOModel.framework/      0 sfml-network.framework/
0 SDL.framework/         0 sfml-system.framework/
0 SDL_image.framework/         0 sfml-window.framework/
0 SDL_mixer.framework/         0 sndfile.framework/
0 SDL_net.framework/
Kleiman-ibook:23 michael$ make
 * [UFO] src/client/cl_console.c
In file included from src/client/client.h:32,
                 from src/client/cl_console.c:30:
src/client/cl_renderer.h:34:17: error: SDL.h: No such file or directory
Code: Kleiman-ibook:23 michael$ egrep CFLAG Makefile
CFLAGS= -I/opt/local/include -arch i386 -arch ppc
SDL_CFLAGS=-FSDL

Naturally, the version works, but apparently that's a no-no (odd, as lots of packages seem to like being packaged inside a directory). Do I really need to add 5 -I statements for the 5 frameworks for SDL to work?

Also: Should the include statement be

#include "SDL.h"
or
#include

Somehow, I thought that quotes were for your local project includes and the angle brackets for system includes.



(placeholder)


_______________________________________________
SDL mailing list

http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org




--
http://codebad.com/
#include "SDL/SDL.h" Vs. #include "SDL.h&
Gabriele Greco
Guest

Quote:

Solution A) Create your own sdl-config. It's really simple.


I think that this solution.
 
Quote:

Solution B) Write a little more code to include the necessary headers. Here's how I accomplished that:

#ifdef APPLE
#  include <SDL/SDL.h>
#  include <OpenGL/GL.h>
#else
#  include <SDL.h>
#  include <GL/gl.h>
#endif



There is also a third solution (C), that I think it's the better:


Add the additional platform dependant include/link paths and flags to your build system files (makefiles, cmakelists.txt, xcode project, visual studio project....).


It's always better to modify a project setting to make a project build on a particular platform/machine/enviroment that have to modify the sources with the risk of breaking the build on another platform or enviroment.



Also, as Eric says, always use "" for non-system headers, not <>.
--
Bye,
 Gabry
#include "SDL/SDL.h" Vs. #include "SDL.h&
Vittorio Giovara
Guest

On Thu, Aug 5, 2010 at 12:45 AM, Donny Viszneki wrote:
Quote:
I solved this problem two ways in my days of Mac OS X developing before Apple stabbed the FOSS community in the back :(

when and how did this happen?
 
Quote:
Solution A) Create your own sdl-config. It's really simple.

Solution B) Write a little more code to include the necessary headers. Here's how I accomplished that:

#ifdef APPLE
#  include <SDL/SDL.h>
#  include <OpenGL/GL.h>
#else
#  include <SDL.h>
#  include <GL/gl.h>
#endif

Of course that solution is just from memory of many years ago, so it has a few rough edges. When you or someone else tries to build your package on another system, it quickly becomes apparent what the problem is and a fix is usually easy to implement, so the absence of a real standard portable one-liner isn't that critical :)


as mentioned by others, #include "SDL.h" will work for most cases on most platforms.
bye
Vittorio
 
#include "SDL/SDL.h" Vs. #include "SDL.h&
Vittorio G.
Guest

On Thu, Aug 5, 2010 at 12:45 AM, Donny Viszneki
wrote:

I solved this problem two ways in my days of Mac OS X developing
before Apple stabbed the FOSS community in the back :(

when and how did this happen?


Solution A) Create your own sdl-config. It's really simple.

Solution B) Write a little more code to include the necessary
headers. Here's how I accomplished that:

#ifdef APPLE
# include <SDL/SDL.h>
# include <OpenGL/GL.h>
#else
# include <SDL.h>
# include <GL/gl.h>
#endif

Of course that solution is just from memory of many years ago, so
it has a few rough edges. When you or someone else tries to build your
package on another system, it quickly becomes apparent what the
problem is and a fix is usually easy to implement, so the absence of a
real standard portable one-liner isn't that critical :)


as mentioned by others, #include "SDL.h" will work for most cases on
most platforms.
bye
Vittorio
_______________________________________________
SDL mailing list

http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
#include "SDL/SDL.h" Vs. #include "SDL.h&
Eric Wing
Guest

On 8/5/10, Gabriele Greco wrote:
Quote:
Quote:


Solution A) Create your own sdl-config. It's really simple.


I think that this solution.


Quote:

Solution B) Write a little more code to include the necessary headers.
Here's how I accomplished that:

#ifdef APPLE
# include <SDL/SDL.h>
# include <OpenGL/GL.h>
#else
# include <SDL.h>
# include <GL/gl.h>
#endif


There is also a third solution (C), that I think it's the better:

Add the additional platform dependant include/link paths and flags to your
build system files (makefiles, cmakelists.txt, xcode project, visual studio
project....).

It's always better to modify a project setting to make a project build on a
particular platform/machine/enviroment that have to modify the sources with
the risk of breaking the build on another platform or enviroment.

Also, as Eric says, always use "" for non-system headers, not <>.

--
Bye,
Gabry


I concur. And FYI, CMake already handles this case correctly and
transparently if you use #include "SDL.h"
#include "SDL_image.h"
et al.

I made sure of that ;)

-Eric
_______________________________________________
SDL mailing list

http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org