Compiling a simple mouse capture code

Hi,

I’m trying to compile a simple mouse capture code using SDL.

I’m using SDL and SDL_image from mercurial repo.

pkg-config paths are correctly configured :

$arif at khost:~/sak/tests$ pkg-config --cflags SDL2_image
-D_REENTRANT -I/opt/SDL/include/SDL2 -I/opt/SDL_image/include/SDL2

$arif at khost:~/sak/tests$ pkg-config --libs SDL2_image
-Wl,-rpath,/opt/SDL/lib -L/opt/SDL/lib -L/opt/SDL_image/lib -lSDL2_image
-lSDL2 -lpthread

But when i try to compile the code :
$arif at khost:~/sak/tests$ gcc pkg-config --cflags --libs SDL2_image
sdl_mouse_capture.c
sdl_mouse_capture.c:3:22: fatal error: SDL2/SDL.h: No such file or directory
compilation terminated.

I’ve included the headers in following way :

#include <SDL2/SDL.h>
#include <SDL2/SDL_image.h>

Thanks in advance.–
Cheers
arif

You’ll also want to do a pkg-config --cflags SDL2 or sdl2-config --cflags

Right now, your command is only grabbing SDL2_image, which may or may not
reside in the same directory.

Hope that helps,
-AlexOn Tue, Jun 11, 2013 at 8:39 AM, arif wrote:

Hi,

I’m trying to compile a simple mouse capture code using SDL.

I’m using SDL and SDL_image from mercurial repo.

pkg-config paths are correctly configured :

$arif at khost:~/sak/tests$ pkg-config --cflags SDL2_image
-D_REENTRANT -I/opt/SDL/include/SDL2 -I/opt/SDL_image/include/SDL2

$arif at khost:~/sak/tests$ pkg-config --libs SDL2_image
-Wl,-rpath,/opt/SDL/lib -L/opt/SDL/lib -L/opt/SDL_image/lib -lSDL2_image
-lSDL2 -lpthread

But when i try to compile the code :
$arif at khost:~/sak/tests$ gcc pkg-config --cflags --libs SDL2_image
sdl_mouse_capture.c
sdl_mouse_capture.c:3:22: fatal error: SDL2/SDL.h: No such file or
directory
compilation terminated.

I’ve included the headers in following way :

#include <SDL2/SDL.h>
#include <SDL2/SDL_image.h>

Thanks in advance.


Cheers
arif

_____________**
SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/**listinfo.cgi/sdl-libsdl.orghttp://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

You’ll also want to do a pkg-config --cflags SDL2 or sdl2-config --cflags

Right now, your command is only grabbing SDL2_image, which may or may not
reside in the same directory.

Hope that helps,
-Alex

Ignore my previous mail. The problem is fixed. The pkg-config is
returning -I/opt/SDL/include/SDL2/ .

So i should have added the headers as #include <SDL.h>, not as #include
<SDL2/SDL.h>

Although my code is still not building. It now spits out following error:
sdl_mouse_capture.c:63:46: error: ?SDL_SRCCOLORKEY? undeclared (first
use in this function)

Although a quick tag search found multiple references to SDL_SRCCOLORKEY

arif at khost:~/sak/SDL$ global -gx SDL_SRCCOLORKEY
SDL_SRCCOLORKEY 408 include/SDL_surface.h SDL_SRCCOLORKEY ignored.
SDL_SRCCOLORKEY 411 include/SDL_surface.h if SDL_SRCCOLORKEY
set, only copy the pixels matching the
SDL_SRCCOLORKEY 422 include/SDL_surface.h if SDL_SRCCOLORKEY
set, only copy the pixels matching the
SDL_SRCCOLORKEY 429 include/SDL_surface.h SDL_SRCCOLORKEY ignored.
SDL_SRCCOLORKEY 432 include/SDL_surface.h if SDL_SRCCOLORKEY
set, only copy the pixels matching the
SDL_SRCCOLORKEY 442 include/SDL_surface.h if SDL_SRCCOLORKEY
set, only copy the pixels matching the
SDL_SRCCOLORKEY 360 src/render/software/SDL_rotate.c if
(src->flags & SDL_TRUE/SDL_SRCCOLORKEY/)
SDL_SRCCOLORKEY 394 src/render/software/SDL_rotate.c
SDL_SetColorKey(src, SDL_TRUE /SDL_SRCCOLORKEY/, colorkey);
SDL_SRCCOLORKEY 463 src/render/software/SDL_rotate.c
SDL_SetColorKey(rz_dst, /SDL_SRCCOLORKEY/ SDL_TRUE | SDL_RLEACCEL,
_colorkey(rz_src));
SDL_SRCCOLORKEY 478 src/render/software/SDL_rotate.c
SDL_SetColorKey(rz_dst, /SDL_SRCCOLORKEY/ SDL_TRUE | SDL_RLEACCEL,
_colorkey(rz_src));
SDL_SRCCOLORKEY 2903 src/video/SDL_video.c if (icon->flags
& SDL_SRCCOLORKEY)

None of them seems to define SDL_SRCCOLORKEY.On 06/11/2013 07:47 PM, Alex Barry wrote:

On Tue, Jun 11, 2013 at 8:39 AM, arif <@arif> wrote:

Hi,

I’m trying to compile a simple mouse capture code using SDL.

I’m using SDL and SDL_image from mercurial repo.

pkg-config paths are correctly configured :

$arif at khost:~/sak/tests$ pkg-config --cflags SDL2_image
-D_REENTRANT -I/opt/SDL/include/SDL2 -I/opt/SDL_image/include/SDL2

$arif at khost:~/sak/tests$ pkg-config --libs SDL2_image
-Wl,-rpath,/opt/SDL/lib -L/opt/SDL/lib -L/opt/SDL_image/lib -lSDL2_image
-lSDL2 -lpthread

But when i try to compile the code :
$arif at khost:~/sak/tests$ gcc pkg-config --cflags --libs SDL2_image
sdl_mouse_capture.c
sdl_mouse_capture.c:3:22: fatal error: SDL2/SDL.h: No such file or
directory
compilation terminated.

I’ve included the headers in following way :

#include <SDL2/SDL.h>
#include <SDL2/SDL_image.h>

Thanks in advance.


Cheers
arif

_____________**
SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/**listinfo.cgi/sdl-libsdl.orghttp://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org


Cheers
arif

You’ll also want to do a pkg-config --cflags SDL2 or sdl2-config --cflags

Right now, your command is only grabbing SDL2_image, which may or may not
reside in the same directory.

Hope that helps,
-Alex

Ignore my previous mail. The problem is fixed. The pkg-config is
returning -I/opt/SDL/include/SDL2/ .

So i should have added the headers as #include <SDL.h>, not as #include
<SDL2/SDL.h>

Although my code is still not building. It now spits out following error:
sdl_mouse_capture.c:63:46: error: ?SDL_SRCCOLORKEY? undeclared (first
use in this function)

Although a quick tag search found multiple references to SDL_SRCCOLORKEY

arif at khost:~/sak/SDL$ global -gx SDL_SRCCOLORKEY
SDL_SRCCOLORKEY 408 include/SDL_surface.h SDL_SRCCOLORKEY
ignored.
SDL_SRCCOLORKEY 411 include/SDL_surface.h if SDL_SRCCOLORKEY
set, only copy the pixels matching the
SDL_SRCCOLORKEY 422 include/SDL_surface.h if SDL_SRCCOLORKEY
set, only copy the pixels matching the
SDL_SRCCOLORKEY 429 include/SDL_surface.h SDL_SRCCOLORKEY
ignored.
SDL_SRCCOLORKEY 432 include/SDL_surface.h if SDL_SRCCOLORKEY
set, only copy the pixels matching the
SDL_SRCCOLORKEY 442 include/SDL_surface.h if SDL_SRCCOLORKEY
set, only copy the pixels matching the
SDL_SRCCOLORKEY 360 src/render/software/SDL_rotate.c if
(src->flags & SDL_TRUE/SDL_SRCCOLORKEY/)
SDL_SRCCOLORKEY 394 src/render/software/SDL_rotate.c
SDL_SetColorKey(src, SDL_TRUE /SDL_SRCCOLORKEY/, colorkey);
SDL_SRCCOLORKEY 463 src/render/software/SDL_rotate.c
SDL_SetColorKey(rz_dst, /SDL_SRCCOLORKEY/ SDL_TRUE | SDL_RLEACCEL,
_colorkey(rz_src));
SDL_SRCCOLORKEY 478 src/render/software/SDL_rotate.c
SDL_SetColorKey(rz_dst, /SDL_SRCCOLORKEY/ SDL_TRUE | SDL_RLEACCEL,
_colorkey(rz_src));
SDL_SRCCOLORKEY 2903 src/video/SDL_video.c if (icon->flags
& SDL_SRCCOLORKEY)

None of them seems to define SDL_SRCCOLORKEY.

Well the problem seems to be that the mouse capture code was written for
earlier version of SDL. Here is the clue, In 1.2.15, there is a macro
definition of SDL_SRCCOLORKEY:

$arif at khost:~/sak/SDL$ hg checkout release-1.2.15
$arif at khost:~/sak/SDL$ global -gx SDL_SRCCOLORKEY
SDL_SRCCOLORKEY 151 include/SDL_video.h #define SDL_SRCCOLORKEY
0x00001000 /**< Blit uses a source color key */On 06/11/2013 08:29 PM, arif wrote:

On 06/11/2013 07:47 PM, Alex Barry wrote:

On Tue, Jun 11, 2013 at 8:39 AM, arif <@arif> wrote:

Hi,

I’m trying to compile a simple mouse capture code using SDL.

I’m using SDL and SDL_image from mercurial repo.

pkg-config paths are correctly configured :

$arif at khost:~/sak/tests$ pkg-config --cflags SDL2_image
-D_REENTRANT -I/opt/SDL/include/SDL2 -I/opt/SDL_image/include/SDL2

$arif at khost:~/sak/tests$ pkg-config --libs SDL2_image
-Wl,-rpath,/opt/SDL/lib -L/opt/SDL/lib -L/opt/SDL_image/lib -lSDL2_image
-lSDL2 -lpthread

But when i try to compile the code :
$arif at khost:~/sak/tests$ gcc pkg-config --cflags --libs SDL2_image
sdl_mouse_capture.c
sdl_mouse_capture.c:3:22: fatal error: SDL2/SDL.h: No such file or
directory
compilation terminated.

I’ve included the headers in following way :

#include <SDL2/SDL.h>
#include <SDL2/SDL_image.h>

Thanks in advance.


Cheers
arif

_____________**
SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/**listinfo.cgi/sdl-libsdl.orghttp://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org


Cheers
arif

You need to include the headers in the following way:

#include “SDL.h”
#include "SDL_image.h"On Tue, Jun 11, 2013 at 5:39 AM, arif wrote:

Hi,

I’m trying to compile a simple mouse capture code using SDL.

I’m using SDL and SDL_image from mercurial repo.

pkg-config paths are correctly configured :

$arif at khost:~/sak/tests$ pkg-config --cflags SDL2_image
-D_REENTRANT -I/opt/SDL/include/SDL2 -I/opt/SDL_image/include/SDL2

$arif at khost:~/sak/tests$ pkg-config --libs SDL2_image
-Wl,-rpath,/opt/SDL/lib -L/opt/SDL/lib -L/opt/SDL_image/lib -lSDL2_image
-lSDL2 -lpthread

But when i try to compile the code :
$arif at khost:~/sak/tests$ gcc pkg-config --cflags --libs SDL2_image
sdl_mouse_capture.c
sdl_mouse_capture.c:3:22: fatal error: SDL2/SDL.h: No such file or
directory
compilation terminated.

I’ve included the headers in following way :

#include <SDL2/SDL.h>
#include <SDL2/SDL_image.h>

Thanks in advance.


Cheers
arif

_____________**
SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/**listinfo.cgi/sdl-libsdl.orghttp://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

I know the documentations says to use that, but whenever I try "SDL.h"
the compiler never finds the header files (probably because it’s in
the SDL2 subdirectory) so I end up using <SDL2/SDL.h> instead.

Of course the fact that the headers are not in predictable locations
seems to be a big issue in the first place. Why can’t we just use the
filenames relative to the include path? (yes, the user could be
providing its own include path, but at that point the user would know
what’s going on anyway)

2013/6/11, Sam Lantinga :> You need to include the headers in the following way:

#include “SDL.h”
#include “SDL_image.h”

On Tue, Jun 11, 2013 at 5:39 AM, arif wrote:

Hi,

I’m trying to compile a simple mouse capture code using SDL.

I’m using SDL and SDL_image from mercurial repo.

pkg-config paths are correctly configured :

$arif at khost:~/sak/tests$ pkg-config --cflags SDL2_image
-D_REENTRANT -I/opt/SDL/include/SDL2 -I/opt/SDL_image/include/SDL2

$arif at khost:~/sak/tests$ pkg-config --libs SDL2_image
-Wl,-rpath,/opt/SDL/lib -L/opt/SDL/lib -L/opt/SDL_image/lib -lSDL2_image
-lSDL2 -lpthread

But when i try to compile the code :
$arif at khost:~/sak/tests$ gcc pkg-config --cflags --libs SDL2_image
sdl_mouse_capture.c
sdl_mouse_capture.c:3:22: fatal error: SDL2/SDL.h: No such file or
directory
compilation terminated.

I’ve included the headers in following way :

#include <SDL2/SDL.h>
#include <SDL2/SDL_image.h>

Thanks in advance.


Cheers
arif

_____________**
SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/**listinfo.cgi/sdl-libsdl.orghttp://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

You’ll also want to do a pkg-config --cflags SDL2 or sdl2-config --cflags

Right now, your command is only grabbing SDL2_image, which may or may not
reside in the same directory.

The problem remains:

$arif at khost:~/sak/tests$ pkg-config --cflags --libs sdl2 SDL2_image
-D_REENTRANT -I/opt/SDL/include/SDL2 -I/opt/SDL_image/include/SDL2
-Wl,-rpath,/opt/SDL/lib -L/opt/SDL/lib -L/opt/SDL_image/lib -lSDL2_image
-lSDL2 -lpthread

$arif at khost:~/sak/tests$ gcc pkg-config --cflags --libs SDL2_image sdl2 sdl_mouse_capture.c
sdl_mouse_capture.c:3:22: fatal error: SDL2/SDL.h: No such file or directory
compilation terminated.On 06/11/2013 07:47 PM, Alex Barry wrote:

Hope that helps,
-Alex

On Tue, Jun 11, 2013 at 8:39 AM, arif <@arif> wrote:

Hi,

I’m trying to compile a simple mouse capture code using SDL.

I’m using SDL and SDL_image from mercurial repo.

pkg-config paths are correctly configured :

$arif at khost:~/sak/tests$ pkg-config --cflags SDL2_image
-D_REENTRANT -I/opt/SDL/include/SDL2 -I/opt/SDL_image/include/SDL2

$arif at khost:~/sak/tests$ pkg-config --libs SDL2_image
-Wl,-rpath,/opt/SDL/lib -L/opt/SDL/lib -L/opt/SDL_image/lib -lSDL2_image
-lSDL2 -lpthread

But when i try to compile the code :
$arif at khost:~/sak/tests$ gcc pkg-config --cflags --libs SDL2_image
sdl_mouse_capture.c
sdl_mouse_capture.c:3:22: fatal error: SDL2/SDL.h: No such file or
directory
compilation terminated.

I’ve included the headers in following way :

#include <SDL2/SDL.h>
#include <SDL2/SDL_image.h>

Thanks in advance.


Cheers
arif

_____________**
SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/**listinfo.cgi/sdl-libsdl.orghttp://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org


Cheers
arif

It sounds like you’re still not including the headers in
sdl_mouse_capture.c like Sam recommended:
#include “SDL.h”

sdl2-config (or pkg-config) should take care of it for you if you include
the headers appropriately, as above.

To do it the “SDL2/SDL.h” way, you need to specify the path where the SDL2
directory can be found. The extra flags you have, like
-I/opt/SDL/include/SDL2,
are pointing at the SDL2 directory, instead of where it can be found:
/opt/SDL/include

Jonny DOn Tue, Jun 11, 2013 at 10:12 AM, arif wrote:

On 06/11/2013 07:47 PM, Alex Barry wrote:

You’ll also want to do a pkg-config --cflags SDL2 or sdl2-config --cflags

Right now, your command is only grabbing SDL2_image, which may or may not
reside in the same directory.

The problem remains:

$arif at khost:~/sak/tests$ pkg-config --cflags --libs sdl2 SDL2_image
-D_REENTRANT -I/opt/SDL/include/SDL2 -I/opt/SDL_image/include/SDL2
-Wl,-rpath,/opt/SDL/lib -L/opt/SDL/lib -L/opt/SDL_image/lib -lSDL2_image
-lSDL2 -lpthread

$arif at khost:~/sak/tests$ gcc pkg-config --cflags --libs SDL2_image sdl2
sdl_mouse_capture.c

sdl_mouse_capture.c:3:22: fatal error: SDL2/SDL.h: No such file or
directory
compilation terminated.

Hope that helps,
-Alex

On Tue, Jun 11, 2013 at 8:39 AM, arif wrote:

Hi,

I’m trying to compile a simple mouse capture code using SDL.

I’m using SDL and SDL_image from mercurial repo.

pkg-config paths are correctly configured :

$arif at khost:~/sak/tests$ pkg-config --cflags SDL2_image
-D_REENTRANT -I/opt/SDL/include/SDL2 -I/opt/SDL_image/include/SDL2

$arif at khost:~/sak/tests$ pkg-config --libs SDL2_image
-Wl,-rpath,/opt/SDL/lib -L/opt/SDL/lib -L/opt/SDL_image/lib -lSDL2_image
-lSDL2 -lpthread

But when i try to compile the code :
$arif at khost:~/sak/tests$ gcc pkg-config --cflags --libs SDL2_image
sdl_mouse_capture.c
sdl_mouse_capture.c:3:22: fatal error: SDL2/SDL.h: No such file or
directory
compilation terminated.

I’ve included the headers in following way :

#include <SDL2/SDL.h>
#include <SDL2/SDL_image.h>

Thanks in advance.


Cheers
arif

_____________****
SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/****listinfo.cgi/sdl-libsdl.orghttp://lists.libsdl.org/**listinfo.cgi/sdl-libsdl.org
<ht**tp://lists.libsdl.org/**listinfo.cgi/sdl-libsdl.orghttp://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

_____________**
SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/**listinfo.cgi/sdl-libsdl.orghttp://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org


Cheers
arif
_____________**
SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/**listinfo.cgi/sdl-libsdl.orghttp://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

It sounds like you’re still not including the headers in
sdl_mouse_capture.c like Sam recommended:
#include “SDL.h”

sdl2-config (or pkg-config) should take care of it for you if you include
the headers appropriately, as above.

To do it the “SDL2/SDL.h” way, you need to specify the path where the SDL2
directory can be found. The extra flags you have, like
-I/opt/SDL/include/SDL2,
are pointing at the SDL2 directory, instead of where it can be found:
/opt/SDL/include

This is fixed. I was including the file etc “SDL/SDL.h” etc, Where
pkg-config is returning /opt/SDL/include/SDL. I should have included it
as “SDL.h”. Thanks for the replyOn 06/12/2013 08:07 PM, Jonathan Dearborn wrote:

Jonny D

On Tue, Jun 11, 2013 at 10:12 AM, arif <@arif> wrote:

On 06/11/2013 07:47 PM, Alex Barry wrote:

You’ll also want to do a pkg-config --cflags SDL2 or sdl2-config --cflags

Right now, your command is only grabbing SDL2_image, which may or may not
reside in the same directory.

The problem remains:

$arif at khost:~/sak/tests$ pkg-config --cflags --libs sdl2 SDL2_image
-D_REENTRANT -I/opt/SDL/include/SDL2 -I/opt/SDL_image/include/SDL2
-Wl,-rpath,/opt/SDL/lib -L/opt/SDL/lib -L/opt/SDL_image/lib -lSDL2_image
-lSDL2 -lpthread

$arif at khost:~/sak/tests$ gcc pkg-config --cflags --libs SDL2_image sdl2
sdl_mouse_capture.c

sdl_mouse_capture.c:3:22: fatal error: SDL2/SDL.h: No such file or
directory
compilation terminated.

Hope that helps,
-Alex

On Tue, Jun 11, 2013 at 8:39 AM, arif <@arif> wrote:

Hi,

I’m trying to compile a simple mouse capture code using SDL.

I’m using SDL and SDL_image from mercurial repo.

pkg-config paths are correctly configured :

$arif at khost:~/sak/tests$ pkg-config --cflags SDL2_image
-D_REENTRANT -I/opt/SDL/include/SDL2 -I/opt/SDL_image/include/SDL2

$arif at khost:~/sak/tests$ pkg-config --libs SDL2_image
-Wl,-rpath,/opt/SDL/lib -L/opt/SDL/lib -L/opt/SDL_image/lib -lSDL2_image
-lSDL2 -lpthread

But when i try to compile the code :
$arif at khost:~/sak/tests$ gcc pkg-config --cflags --libs SDL2_image
sdl_mouse_capture.c
sdl_mouse_capture.c:3:22: fatal error: SDL2/SDL.h: No such file or
directory
compilation terminated.

I’ve included the headers in following way :

#include <SDL2/SDL.h>
#include <SDL2/SDL_image.h>

Thanks in advance.


Cheers
arif

_____________****
SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/****listinfo.cgi/sdl-libsdl.orghttp://lists.libsdl.org/**listinfo.cgi/sdl-libsdl.org
<ht**tp://lists.libsdl.org/**listinfo.cgi/sdl-libsdl.orghttp://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

_____________**
SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/**listinfo.cgi/sdl-libsdl.orghttp://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org


Cheers
arif
_____________**
SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/**listinfo.cgi/sdl-libsdl.orghttp://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org


Cheers
arif