fachtnaroe.net
— because if it was easy, everyone would do it

  • Credits : John S and John C

Coding is one of the highest art forms achieved by mankind; an idea - just an electrical impulse - is made real in an alternate electronic universe; the created idea however, does not have physical form, and yet can change the physical world; it cannot be touched, and yet may touch all mankind.

Strawberry Perl and SDL

OS: MS Windows; Release: 7; Arch: x86_64;

If you want to use perl and SDL on Windows, you'll need to download a version of perl for MS Windows.

(The source code is available, but you'll find it easiest when getting started to work with binaries - which is the normal software distribution mode for Windows.)

Before you start, you'll probably want to download:

  1. WinZip
  2. gedit
  3. FileZilla
  4. You may also prefer using Console instead of Windows cmd

The preferred implementation of perl for Windows is Strawberry Perl. You can download that here: (http://strawberryperl.com/). If you have previously tried to install another perl, uninstall that and reboot before continuing.

During the installation accept all the options which are offered by the installation program. Perl will be installed in C:\strawberry. If you accepted and said 'yes' to all options at installation, the perl command will now be in your path.

You'll know that you've installed Strawberry correctly by navigating to a folder with a perl program in it; right-click and you should see the default option is 'Execute Perl Program'.

(You should use FileZilla to download files from the programming server with which you can test the installation of perl and SDL.)

For purposes of this how-to, you should now start a command prompt session.

For convenience, change directory to C:\strawberry and copy into it the test files you downloaded.

When you run a program at the Windows CLI, either type:

perl somefile.pl
or
somefile.pl
- you shouldn't type ./ before the file name and you won't need to chmod the file before running.

If you've downloaded a test file with a use SDL statement you should get an error if you try to run it, since we don't have SDL installed yet. Test this now. Sample output is here:

C:\strawberry\test>perl somefile.pl
Can't locate SDL.pm in @INC (@INC contains: C:/strawberry/perl/site/lib
C:/strawberry/perl/vendor/lib C:/strawberry/perl/lib .) at somefile.pl line 2.
BEGIN failed--compilation aborted at somefile.pl line 2.

Now we can configure cpan.

Type:

cpan Bundle::CPAN
and accept any options offered (just press return). When this is done, type:
exit
to return to the DOS prompt.

Now type:

cpan SDL
and watch your screen. Accept anything offered as an option (just press return). You may see a Windows alert about a program not responding. If the alert appears it should be about mixer_channels. Close the alert and wait for the program to complete.

If you saw no errors you'll see a success message at the end of installation and you can proceed with testing your program. You should now have a working perl and SDL on Windows.

If you did see an alert you'll probably see a message like this below at the end of the installation attempt:

Test Summary Report
-------------------
t\core.t                      (Wstat: 0 Tests: 28 Failed: 0)
  TODO passed:   21-22
t\core_video.t                (Wstat: 0 Tests: 110 Failed: 0)
  TODO passed:   57, 59
t\mixer_channels.t            (Wstat: 65280 Tests: 35 Failed: 0)
  Non-zero exit status: 255
  Parse errors: No plan found in TAP output
Files=59, Tests=3824, 201 wallclock secs ( 0.76 usr +  0.02 sys =  0.78 CPU)
Result: FAIL 
Failed 1/59 test programs. 0/3824 subtests failed. Won't install without force
  JTPALMER/SDL-2.540.tar.gz
  C:\strawberry\perl\bin\perl.exe ./Build test -- NOT OK
//hint// to see the cpan-testers results for installing this module, try:
  reports JTPALMER/SDL-2.540.tar.gz
Stopping: 'test' failed for 'SDL'.

If your error message is like that shown above (with only that 1 error), you can try to force the installation as follows:

cpan -f SDL

During the forced installation you will still see an alert message; and at the end you'll likely see an error message also. Even so, test your program. The final error message itself is probably an error resulting from the force. You should now have a working perl and SDL.

If you see a different error message to that shown above, read the Strawberry support/documentation page. After that, considering uninstalling, rebooting, re-installing and then consider forcing again.

If Perl runs but you have problems similar to here, try using SDL::get_error as described there to get more information on any error.


Last updated: 20150326-09:43