How do i fix this?

An embedded and charset-unspecified text was scrubbed…
Name: not available
URL: http://lists.libsdl.org/pipermail/sdl-libsdl.org/attachments/20010913/753a37a2/attachment.txt

Unless you put

#include <SDL/SDL.h>

it won’t find the headers. The preferrable way to compile is to put

#include “SDL.h”

and then compile like

gcc -g -Wall -o test test.c sdl-config --cflags --libs

So that the correct compile and link flags are present.On Thu, 2001-09-13 at 17:12, Josiah Gordon wrote:

I just wrote my first program SDL program in Linux and when I went to compile it
I got a message saying that SDL_Init was used without being initialized. I have
#include <SDL.h> at the top of my program. What am I doing wrong? Thanks.

Josiah


Sent via Fetchmail - free email service at http://www.fetchmail.com


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl


Ti Leggett
leggett at eecs.tulane.edu

I just wrote my first program SDL program in Linux and when I went to
compile it I got a message saying that SDL_Init was used without being
initialized. I have #include <SDL.h> at the top of my program. What am
I doing wrong? Thanks.

You should do #include “SDL.h” (not <SDL.h>), for one thing. Next, make
sure that SDL.h is in your include path:

gcc -o test test.c -I/usr/local/include/SDL

…this is better done as:

gcc -o -test test.c sdl-config --cflags sdl-config --libs

(Note the direction of those single quote chars.)

–ryan.

“Ryan C. Gordon” wrote:

You should do #include “SDL.h” (not <SDL.h>), for one thing. Next, make
sure that SDL.h is in your include path:

I always use <SDL.h>, since <> and “” mean the same thing except that “” first
searches the directory associated to the current source file, and since
SDL.h is not part of your project but a header installed somewhere,
<SDL.h> is probably what you want. In practice it should rarely make a
difference however

(ref: 6.10.2 of the C Standard, and your compiler manual)

gcc -o -test test.c sdl-config --cflags sdl-config --libs

I prefer

gcc `sdl-config --cflags` -o test test.c `sdl-config --libs`

to more clearly separate compilation options from libraries; knowing
how this works also helps you writing correct Makefiles

I always use <SDL.h>, since <> and “” mean the same thing except that “” first
searches the directory associated to the current source file, and since
SDL.h is not part of your project but a header installed somewhere,
<SDL.h> is probably what you want. In practice it should rarely make a
difference however

There are some environments under which the compiler will not find the
SDL headers if they are included with <SDL.h>, because the SDL headers
are not installed in one of the system paths. For this reason, I always
recommend including “SDL.h”

See ya,
-Sam Lantinga, Software Engineer, Blizzard Entertainment

Sam Lantinga wrote:

There are some environments under which the compiler will not find the
SDL headers if they are included with <SDL.h>, because the SDL headers
are not installed in one of the system paths. For this reason, I always
recommend including “SDL.h”

which ones? Standard behaviour in all compilers I’ve ever used has been to
put explicitly added directories (like those given by -I flags) to the <>
set, not to the ("" - <>) set

I just checked and one of my programs and I set it to

#include <GL/gl.h>
#include <GL/glu.h>
#include <SDL/SDL.h>

as its installed in the libs and includes dir i set it to reference it
like the GL stuff. Isnt this more simple?

JG

Sam Lantinga wrote:

I always use <SDL.h>, since <> and “” mean the same thing except that “” first
searches the directory associated to the current source file, and since
SDL.h is not part of your project but a header installed somewhere,
<SDL.h> is probably what you want. In practice it should rarely make a
difference however

There are some environments under which the compiler will not find the
SDL headers if they are included with <SDL.h>, because the SDL headers
are not installed in one of the system paths. For this reason, I always
recommend including “SDL.h”

See ya,
-Sam Lantinga, Software Engineer, Blizzard Entertainment

Hypermedia Research Centre
Sanyo R&D Headquarters, Tokyo
http://www.sanyo.co.jp/R_and_D/3dm/
Tel: +81 (0)3 5803 3566
Fax: +81 (0)3 5803 3640
Email: jg at tk.hm.rd.sanyo.co.jp
Please use open standard file formats for attachments

I’d have to agree with Sam here, the “SDL.h” is really the way IMO it should be,
generally i’ve been told that only system includes use the <> all user
libraries, etc. use “”…

-ShawnOn Mon, Sep 17, 2001 at 11:01:23AM +0900, J Grant wrote:

I just checked and one of my programs and I set it to

#include <GL/gl.h>
#include <GL/glu.h>
#include <SDL/SDL.h>

as its installed in the libs and includes dir i set it to reference it
like the GL stuff. Isnt this more simple?

But, isn’t <> supposed to search the standard include locs, ie.
/usr/include etc. ? So, iow, #include <SDL/SDL.h> would work on all
platforms ? Or am i horribly wrong here ?

Anyway, it’s nice if all SDL progs use the same include style, so
i’ll use the one Sam recommended, i’m just curious =)

Sorry if this is getting off topic, btw. I’ll shut up now =)On Monday 17. September 2001 04:10, you wrote:

On Mon, Sep 17, 2001 at 11:01:23AM +0900, J Grant wrote:

I just checked and one of my programs and I set it to

#include <GL/gl.h>
#include <GL/glu.h>
#include <SDL/SDL.h>

as its installed in the libs and includes dir i set it to
reference it like the GL stuff. Isnt this more simple?

I’d have to agree with Sam here, the “SDL.h” is really the way IMO
it should be, generally i’ve been told that only system includes
use the <> all user libraries, etc. use “”…


Trick


Linux User #229006 * http://counter.li.org

But, isn’t <> supposed to search the standard include locs, ie.
/usr/include etc. ? So, iow, #include <SDL/SDL.h> would work on all
platforms ? Or am i horribly wrong here ?

#include <SDL/SDL.h> doesn’t work with Visual C.

Murlock----------------
Gloire ? mon saigneur Arioch
Murlock (http://www.murlock.org)

in VC++ is the SDL dir not in the includes path?

JG

Murlock wrote:>

But, isn’t <> supposed to search the standard include locs, ie.
/usr/include etc. ? So, iow, #include <SDL/SDL.h> would work on all
platforms ? Or am i horribly wrong here ?

#include <SDL/SDL.h> doesn’t work with Visual C.

Murlock

J Grant wrote:

Murlock wrote:

#include <SDL/SDL.h> doesn’t work with Visual C.

in VC++ is the SDL dir not in the includes path?

When using VC++, the SDL headers reside in their own “include” directory
someplace. In this case, there is no “SDL” directory, and if there is one,
it does not contain any header files. It basically boils down to the fact
that library installations on Windows typically don’t add subdrectories to
the compiler’s “include” directory.

  • Randi

Regimental Command
Generic Armored Combat System
http://regcom.sourceforge.net