Hi David and others,

I can't get an SDL window up from a Perl script under OS X.  From
Google searches it sounds like I'm not the first.  David's last message
here suggests that maybe it's never worked on OS X.

However, I've managed to boil the problem down to the bare bones (see
below).  Any suggestions gladly received.

OS X 10.2.8
SDL-1.2.9
SDL_Perl-2.1.3
perl -v
This is perl, v5.6.0 built for darwin

>From Perl, just trying to open a window gives a load of error messages
starting with "kCGErrorInvalidConnection : CGSNewWindow: Invalid
connection" and then a bus error.


First I checked out the C demo programs - they run fine.  So I made an
extremely simple C program:

#include "SDL.h"

int main(int argc, char *argv[])
{
  SDL_Surface *screen;

  screen = SDL_SetVideoMode(640, 480, 16, 0);

  if ( screen == NULL ) {
    fprintf(stderr, "Couldn't set video mode");
    exit(1);
  }
  return(0);
}

and compiled it with:

gcc -o basicsdl basicsdl.c -I/usr/local/include/SDL -L/usr/local/lib
-lSDLmain -lSDL -framework Cocoa -framework OpenGL

and it runs OK (a window appears momentarily as expected)


I then look deep into the SDL_Perl-2.1.3 build process, and can't find
anything wrong with paths, includes, frameworks and so on.  So I cut
SDL_Perl out of the mix and use Inline:C as follows:

#!/usr/bin/perl -w

use Inline C => 'DATA' =>
  LIBS => '-L/usr/local/lib -lSDLmain -lSDL -framework Cocoa -framework
OpenGL',
  INC => '-I/usr/local/include/SDL';

my $ret = sdl_init();
print "got $ret\n";

__DATA__
__C__

#include "SDL.h"

int sdl_init() {
  SDL_Surface *screen;

  screen = SDL_SetVideoMode(640, 480, 16, 0);

  if ( screen == NULL ) {
    fprintf(stderr, "Couldn't set video mode");
    exit(1);
  }
  return(0);
}


This program gives the same errors as a SDL_Perl script.  It sounds
like some kind of context problem but I'm no expert on this I'm afraid.

Thanks for reading this far!

cheers,
Bob.

Reply via email to