I have an old script which is using the SDL::Mixer. But it is not running anymore. Installing SDL::Mixer via cpan failed for me. So I installed it via sudo apt-get install libsdl-perl.

I tried to run the following code:

#!/usr/bin/perl use strict; use warnings; use SDL::Mixer; my $mixer = SDL::Mixer->new( -frequency => 22050, -channels => 2, -size => 1024);

But I get the following error message:

Can't locate object method "new" via package "SDL::Mixer" at test.pl l +ine 8.

I have no idea what to do. Is SDL::Mixer not correctly installed? What do you recommend? Thank you very much!

Some more information: The following code tells me that I have version 1.2.12 installed.

use SDL::Mixer; use SDL::Version; my $version = SDL::Mixer::linked_version(); printf("%d.%d.%d\n", $version->major, $version->minor, $version->patch +);
The code in my script which I wrote in 2013 to play a wav-file looks as follows:
use SDL::Mixer; use SDL::Music; playMusicFile("test.wav"); BEGIN { my $music; my $mixer = SDL::Mixer->new( -frequency => 22050, -channels => 2, -size => 1024); sub playMusicFile { my $music_file = $_[0]; $music = new SDL::Music $music_file; $mixer->music_volume(40); $mixer->play_music($music, 0); } }

But as told before it is not working anymore.


In reply to SDL::Mixer for Ubuntu 19.04 by Dirk80

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.