Search code examples
windowsperlsdlcpanstrawberry-perl

Why can't I install SDL on any of my portable perl installations on windows?


At school we have been told to do a private project, in a language of our choosing. I chose perl, and for the graphics (compulsory component) chose SDL.

Earlier I had installed portable-git, and the git-bash thing came with perl. Hooray! It worked! Let's install sdl!

cpan SDL

output:

Can't locate CPAN/Author.pm in @INC (you may need to install the CPAN::Author module)

This confused me, especially when I get the same message for cpan CPAN::Author. So I install a portable version of strawberry-perl (school computer security settings forbid installation of software by non-admins), and I get a different error message (after loading a bunch of stuff):

Welcome to Alien::SDL module installation                                                                               
-----------------------------------------                                                                                 
checking operating system... MSWin32                                                                                    
checking for gcc... yes                                                                                                 
checking build system type... MSWin32-x64-multi-thread                                                                  
checking platform specific module... using 'My::Builder::Windows'                                                       
checking SDL_INST_DIR env var... no                                                                                     
checking for config script... no                                                                                        
checking for prebuilt binaries... no                                                                                                                                                                                                            
You have the following options:                                                                                         
[1] Quit installation                                                                                                                                                                                                                           
What way do you wanna go? [1 ]1                                                                                         
No 'Build' created  FROGGS/Alien-SDL-1.446.tar.gz                                                                         
C:\Users\gardner.mark.INFOLAB\Downloads\strawberry-perl\perl\bin\perl.exe 
Build.PL -- NOT OK                          Stopping: 'install' failed for 
'Alien::SDL'. 

I have tried cpan Alien::SDL, and using the -f flag on both commands, but I still get the same message. Do I need to install something else, or what is the problem?

EDIT: as @xxfelixxx suggested, I installed cpanm successfully. However, that gives the following output, with an error (in bold):

--> Working on SDL                                                                                                      
Fetching http://www.cpan.org/authors/id/F/FR/FROGGS/SDL-2.548.tar.gz ... OK                                             
==> Found dependencies: Alien::SDL, Tie::Simple                                                                         
--> Working on Alien::SDL                                                                                               
Fetching http://www.cpan.org/authors/id/F/FR/FROGGS/Alien-SDL-1.446.tar.gz... OK
Configuring Alien-SDL-1.446 ... N/A                                                                                     
! Configure failed for Alien-SDL-1.446. See [...]\STRAWB~1\data\.cpanm\work\1527577290.7232\build.log for details.                                                                                                     
--> Working on Tie::Simple                                                                                             
Fetching http://www.cpan.org/authors/id/H/HA/HANENKAMP/Tie-Simple-1.04.tar.gz ... OK                                    
Configuring Tie-Simple-1.04 ... OK                                                                                      
Building and testing Tie-Simple-1.04 ... OK                                                                             
Successfully installed Tie-Simple-1.04                                                                                  
! Installing the dependencies failed: Module 'Alien::SDL' is not installed                                              
! Bailing out the installation for SDL-2.548.                                                                           
1 distribution installed 

So, as earlier, Alien::SDL fails to configure itself.


Solution

  • Short answer to the topicstarter:

    Both SDL 1.x library and Alien:SDL perl module seem unmaintained, everyone went to SDL2 and Alien::SDL2

    And so should you.

    I installed Strawberry 5.30 Win64 and then I resolved obvious problems with file/folder access rights because I DO NOT want to run Perl or Perl games as Administrator user.

    • d:\Strawberry\cpan\
    • d:\Strawberry\perl\

    Then I just issued Windows shell command cpan install Alien:SDL2 - and it installed like a charm.

    Alternatively it seems to be possible to install Alien:SDL version 1 but that would need Win32/x86 version of Strawberry Perl, not Win64/x64 version. But... why? According to http://yapgh.blogspot.com the SDL v.1 is dead since March 2013.


    Just adding more details.
    Was hit by this too....
    My wish is just to run Frozen Bubbles game on Win10 x64 box.
    I have some experience with programming, but not in Perl, nor do I have Perl IDE or something.
    I don't want any Perl programming hassle, I just want to make the game run.

    I dropped here from Google for the same error message, so this maybe will help to somebody else too, whom Google maybe will forward here too.


    Like I said, SDL 1.x library and Alien:SDL perl module are unmaintained.

    However FrozenBubble game is not maintained any more too and only works with SDL 1.x


    CPAN testing has the following record for Alien::SDL on Windows: http://www.cpantesters.org/cpan/report/154af118-6c11-1014-a593-b7c73b50a26f

    Notable things:

    • it used Strawberry 5.28.2 not 5.30,
    • it uses x86/Win32 not x64/Win63
    • it quotes gccversion='7.1.0' ( Straberry 5.30 win64 seems to have 8.3)

    So it seems to boil down to question, whether ABI for Win64 of GCC 7.1 and 8.3 is the same or not.


    The error seems triggered by this file:

    • d:\Strawberry\cpan\build\Alien-SDL-1.446-0\inc\My\Utility.pm

    It has $prebuilt_binaries array listing some - whd'ya think? - pre-built SDL 1.x libraries. It has 3 options for Win32 prebuilt SDL1.x and two options for Win64:

    • BEWARE: binaries are using old ABI option just for old strawberryperl 5.12.x/64bit and GCC 4.4.3
    • RECOMMENDED one for GCC gccversion_re => qr/^4\.(4\.[5-9]|[5-9]\.[0-9])$/
    • Notice: the GCC Version element is missed (no check) for Win32 library binaries!

    That file also has a sub check_prebuilt_binaries which loops through the array and tries to match found Perl environment to those criteria.

    The second line of the sub was commented out debug printf of environment to be checked (except for GCC). I de-commented it, moved upward and extended to include GCC.

    sub check_prebuilt_binaries
    {
      print "(os=$^O cc=$cc archname=$Config{archname} gccVer=$Config{gccversion})\r\n";
      print "checking for prebuilt binaries... ";
      my @good = ();
      foreach my $b (@{$prebuilt_binaries}) {
        if ( ($^O =~ $b->{os_re}) &&
             ($Config{archname} =~ $b->{arch_re}) &&
             ($cc =~ $b->{cc_re}) &&
             (!defined $b->{gccversion_re} || $Config{gccversion} =~ $b->{gccversion_re})
            ) {
          $b->{buildtype} = 'use_prebuilt_binaries';
          push @good, $b;
        }
      }
      scalar(@good)
        ? print "yes, " . scalar(@good) . " option(s)\n"
        : print "no\n";
      #returning ARRAY of HASHREFs (sometimes more than one value)
      return \@good;
    }
    

    Then I run Perl Build and here is what I got:

    d:\Strawberry\cpan\build\Alien-SDL-1.446-0>perl ./Build.PL
    Welcome to Alien::SDL module installation
    -----------------------------------------
    checking operating system... MSWin32
    checking for gcc... yes
    checking build system type... MSWin32-x64-multi-thread
    checking platform specific module... using 'My::Builder::Windows'
    checking SDL_INST_DIR env var... no
    checking for config script... no
    (os=MSWin32 cc=gcc archname=MSWin32-x64-multi-thread gccVer=8.3.0)
    checking for prebuilt binaries... no
    
    You have the following options:
    [1] Quit installation
    
    What way do you wanna go? [1 ]1
    

    I am not good regexper, but for what I can see the GCC Win64 version is pinned to be 4.4.5+ or 4.5.x - and no version 5.0+ are allowed. Probably they did not exist when Alien:SDL was last committed.


    GCC release notes mention ABI change w.r.t. x86-64 rather often, for example:

    etc.

    Which specific Win64 GCC ABI changes can be crucial for LibSDL I don't know. But it seems from CPAN test that at least Win32 ABI changes between GCC 4.5 and 7.1 were not that bad. Anyway, compiling SDL 1.x with modern GCC from sources would definitely be above my capabilities. So, take it or leave it...


    Hoping for the good, I just removed (commented out) the GCC version test for the "recommended" Win64 SDL1 pre-built binaries.

    d:\Strawberry\cpan\build\Alien-SDL-1.446-0>perl ./Build.PL test
    Welcome to Alien::SDL module installation
    -----------------------------------------
    checking operating system... MSWin32
    checking for gcc... yes
    checking build system type... MSWin32-x64-multi-thread
    checking platform specific module... using 'My::Builder::Windows'
    Too early to specify a build action 'test'.  Do 'Build test' instead.
    
    d:\Strawberry\cpan\build\Alien-SDL-1.446-0>perl ./Build test
    Fetching 'http://strawberryperl.com/package/kmx/sdl/Win64_SDL-1.2.14-extended-bin_20111205.zip'...
    Checking checksum for 'download\Win64_SDL-1.2.14-extended-bin_20111205.zip'...
    Extracting download\Win64_SDL-1.2.14-extended-bin_20111205.zip...
    t\001_load.t ................ 1/1 # Testing Alien::SDL 1.446, Perl 5.030000, D:\Strawberry\perl\bin\perl.exe
    # Build type: use_prebuilt_binaries
    # Detected sdl-config script: n.a.
    # Build option used:
    #       Binaries Win/64bit SDL-1.2.14 (extended, 20111205) RECOMMENDED
    #       (gfx, image, mixer, net, smpeg, ttf, sound, svg, rtf, Pango)
    # URL:
    #       http://strawberryperl.com/package/kmx/sdl/Win64_SDL-1.2.14-extended-bin_20111205.zip
    #       http://froggs.de/libsdl/Win64_SDL-1.2.14-extended-bin_20111205.zip
    # SHA1: 35f3b496ca443a9d14eff77e9e26acfa813afafd
    t\001_load.t ................ ok
    t\002_config.t .............. 1/6 # Prefix='D:\Strawberry\cpan\build\Alien-SDL-1.446-0\blib\lib\auto\share\dist\Alien-SDL\1.446_6ae293a9\bin\..\'
    t\002_config.t .............. ok
    t\003_check_header.t ........ # Testing basic headers SDL.h + SDL_version.h
    [Alien::SDL] Testing header(s): SDL.h
    t\003_check_header.t ........ 1/2 L.h, SDL_version.h
    t\003_check_header.t ........ ok
    t\004_get_header_version.t .. 1/1 # Core version: 1.2.14
    t\004_get_header_version.t .. ok
    t\release-pod-coverage.t .... skipped: these tests are for release candidate testing
    t\release-pod-syntax.t ...... skipped: these tests are for release candidate testing
    All tests successful.
    Files=6, Tests=10,  8 wallclock secs ( 0.06 usr +  0.05 sys =  0.11 CPU)
    Result: PASS
    

    Yahoo! works!!! or so it seems....


    Now I can finally use CPAN to install the lib and the game?

    …sadly, not.

    CPAN probably detects I tinkered with the sources (checksum failures), re-fetches vanilla library into a new d:\Strawberry\cpan\build\Alien-SDL-1.446-1\ folder - and fails build with the same error as above. No good.

    At least perl ./Build.PL install worked, but this library albeit installed locally was hardly registered in local CPAN registry because being installed outside CPAN framework?..

    Probably CPAN gurus would manage to either pin local version faking CPAN checksums, or just would upload updated SDL module to CPAN, but... I am not them.

    cpan> install  Games::FrozenBubble
    Running install for module 'Games::FrozenBubble'
    Checksum for D:\Strawberry\cpan\sources\authors\id\K\KT\KTHAKORE\Games-FrozenBubble-2.212.tar.gz ok
    

    ……

    Running make test for DRTECH/Locale-Maketext-Lexicon-1.00.tar.gz
    "D:\Strawberry\perl\bin\perl.exe" "-MExtUtils::Command::MM" "-MTest::Harness" "-e" "undef *Test::Harness::Switches; test_harness(0, 'blib\lib', 'blib\arch')" t/*.t
    t/1-basic.t ...................... 1/33 "msgunfmt" не является внутренней или внешней
    командой, исполняемой программой или пакетным файлом.
    t/1-basic.t ...................... ok
    …… 
    t/55-runextract.t ................ ok
    t/6-gettext.t .................... 1/30 "msgunfmt" не является внутренней или внешней
    командой, исполняемой программой или пакетным файлом.
    t/6-gettext.t .................... ok
    …...
    t/preload.t ...................... ok
    t/release-eol.t .................. skipped: these tests are for release candidate testing
    t/release-pod-syntax.t ........... skipped: these tests are for release candidate testing
    All tests successful.
    Files=17, Tests=361, 11 wallclock secs ( 0.22 usr +  0.17 sys =  0.39 CPU)
    Result: PASS
    

    PASS??? Really?


    with few more patches - it runs though. Nostalgy... https://github.com/kthakore/frozen-bubble/issues/72