I'm trying to get SDLPerl working on my 64-bit Snow Leopard machine with Perl 5.10.1, and after solving many other problems, I got to RT #49975, where it's time to make the Mac bundle.

Since I was compiling SDL myself, I also had to fetch the latest JPEG, PNG, and TIFF libraries, as well as SDL_Image. The build file in SDL_Perl is verbose, so it doesn't say what it found or what it didn't find. I compile and install all of those before I build the Perl module. After installing SDL_Perl, I have to build the bundle so I can get the SDLPerl program I need to run the applications. That's another set of problems.

First, I fixed the Darwin.pm script to use the same perl that I'm building against. Never, never, never use the literal name "perl" in your build systems. Always use $^X so you get the perl the build is using. In this case, I don't want the system perl.

Next, Chris Nandor clued me into selecting the right architecture. By default, when I try to build the bundle it looks like it is try to make a fat one. I didn't build SDL, etc. for fat though. I just have to tell it which architecture I want:

% env ARCHFLAGS="-arch x86_64" ./Build bundle

Now it mostly compiles, but I'm not so sure those warnings are harmless:

Building SDL_Perl gcc -I/usr/local/include/SDL -D_GNU_SOURCE=1 -D_THREAD_SAFE -fno-common -DPERL_DARWIN -no-cpp-precomp -fno-strict-aliasing -pipe -fstack-protector -I/usr/local/perls/perl-5.10.1/lib/5.10.1/darwin-2level/CORE MacOSX/launcher.m -L/usr/local/lib -lSDL -Wl,-framework,Cocoa -fstack-protector -L/usr/local/perls/perl-5.10.1/lib/5.10.1/darwin-2level/CORE -lperl -ldl -lm -lutil -lc -framework Cocoa -o "SDLPerl.app/Contents/MacOS/SDLPerl"In file included from /usr/local/perls/perl-5.10.1/lib/5.10.1/darwin-2level/CORE/perl.h:2424, from MacOSX/launcher.m:14: /usr/local/perls/perl-5.10.1/lib/5.10.1/darwin-2level/CORE/handy.h:108:1: warning: "bool" redefined In file included from /System/Library/Frameworks/CoreFoundation.framework/Headers/CFBase.h:39, from /System/Library/Frameworks/CoreFoundation.framework/Headers/CoreFoundation.h:38, from /System/Library/Frameworks/Foundation.framework/Headers/Foundation.h:6, from MacOSX/launcher.m:11: /usr/lib/gcc/i686-apple-darwin10/4.2.1/include/stdbool.h:36:1: warning: this is the location of the previous definition MacOSX/launcher.m: In function '-[SDLPerlMain launchPerl:]': MacOSX/launcher.m:136: warning: passing argument 2 of 'Perl_sys_init3' from incompatible pointer type

It's time to try it out, though. I create the lander.pl tutorial example:

% perl5.10.1 -MSDL::Tutorial::LunarLander=lander.pl -e1

I'm in the SDL_Perl directory still, so I need to give some long paths to everyone finds themselves:

% SDLPerl.app/Contents/MacOS/SDLPerl `pwd`/lander.pl

This almost works, but lander.pl can't find any of it's files. The working directory is off, so I fix that up in lander.pl :

use File::Basename; my $dir = dirname( $0 ); chdir $dir;

Now the application window starts up and it paints it background and the first instance of the lander. That's as far as it gets before it SDLPerl unexpectedly quits (the crash report is at the end of the post). It doesn't like the call to update in draw . Comment out that line and everything is fine except I can't see anything happening in the application window.

I look at some other examples and note that they don't use update . Instead, they use sync. I change the line in draw to use sync instead, and now it works, although it dumps core at the end (after the Perl script exits):

# in draw #$app->update($background_rect); $app->sync;

Now I get the nice animation, although it took me a couple of tries to figure out it wasn't interactive. I kept trying to land it myself with arrow keys!

And, the crash report: