Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Unable to use Device::SerialPort on Mac OS X

by Metphoto (Initiate)
on Aug 16, 2009 at 09:42 UTC ( [id://788999]=perlquestion: print w/replies, xml ) Need Help??

Metphoto has asked for the wisdom of the Perl Monks concerning the following question:

Hello fellow brothers, forgive me for I am novice.

I have only just started to learn Perl. I wanted to write a small app to read data from a serial device attached to my Mac.

So I wrote this:

#!/usr/bin/perl use warnings; use diagnostics; use strict; #use 5.010; Only v5.8.8 on a Mac. use lib '/opt/local/lib/perl5/site_perl/5.8.8/darwin-2level'; use Device::SerialPort qw( :PARAM :STAT 0.07 );
When I run this app I get this error:
Can't load '/opt/local/lib/perl5/site_perl/5.8.8/darwin-2level/auto/De +vice/SerialPort/SerialPort.bundle' for module Device::SerialPort: dlo +pen(/opt/local/lib/perl5/site_perl/5.8.8/darwin-2level/auto/Device/Se +rialPort/SerialPort.bundle, 1): Symbol not found: _PL_stack_base Referenced from: /opt/local/lib/perl5/site_perl/5.8.8/darwin-2level/ +auto/Device/SerialPort/SerialPort.bundle Expected in: dynamic lookup at /opt/local/lib/perl5/site_perl/5.8.8/darwin-2level/Device/SerialPo +rt.pm line 62 Compilation failed in require at ./water.pl line 9.

The key part of the message seems to be "Symbol not found: _PL_stack_base"

I have reinstalled Device::SerialPort from CPAN. That appeared to work.

I downloaded the package directly from CPAN and tried to re-make the module, using something like (I cant seem to find the exact instructions I used): perl Makefile.PL make make test sudo make install

As far as I can tell I have only one copy of SerialPort.pm installed.

I am running this on a Apple Mac using OS X 10.5.8, with a Core Duo CPU, i.e. 32bit. Perl is v5.8.8.

I did read somewhere that SerialPort.pm was Linux only. Is that true?

Any ideas?

TIA

Mark

Replies are listed 'Best First'.
Re: Unable to use Device::SerialPort on Mac OS X
by broomduster (Priest) on Aug 16, 2009 at 19:47 UTC
    I am using Device::SerialPort with no problems on 10.4.11 (Tiger). I know of folks using it successfully on 10.5.x.

    I think AnonyMonk is pointing you in the right direction w.r.t. multiple Perl installations. You start with #!/usr/bin/perl, which is the Apple-supplied Perl. But all that /opt/local/... points at MacPorts, which suggests that you also have a Perl installation from there (probably /opt/local/bin/perl; try saying which perl on the command line). My guess is that even though you think you installed Device::SerialPort by hand, you either did so using the MacPorts Perl, or you really installed it via MacPorts (looks to me that they have a port for that).

    Check to be sure that you really do have a MacPorts-installed Perl and change your shebang line accordingly. As AnonyMonk suggests, also try reinstalling Device::SerialPort if the altered shebang does not work.

    Disclaimer: I don't use MacPorts, so these are Intelligent Guesses, not Definitive Truth.

    Updated: I see you also posted back while I was replying and that you are back on track. If you change the first line of your script to

    #!/opt/local/bin/perl
    you will get the right Perl installation and not have to do /opt/local/bin/perl < filename on the command line.
      Hi

      I have just fixed the issue. Actually before I read your reply.

      It turned you were spot on!

      Some time ago I had used Porticus to install Wireshark, which POSSIBLY installed the other install of Perl. Certainly Porticus was listing a version of Perl.

      So I used Porticus to remove the naughty Perl and then reinstalled Device::SerialPort from CPAN.

      Finally I removed the unnecessary 'use lib' line from my code and bingo it works!

      Today has been a good learning experience.

      Thanks oh great monks.

      Mark

Re: Unable to use Device::SerialPort on Mac OS X
by Anonymous Monk on Aug 16, 2009 at 10:13 UTC
    How many perl do you have installed? With or without threading (perl -V)? Try uninstalling Device::SerialPort then reinstalling. Make sure you use the same perl for run your program and for install Device::SerialPort.
      Hi

      On your advice I looked at the versions of Perl on my Mac.

      If I do a 'which perl' I get /opt/local/bin/perl.

      However I also found another version of Perl at /usr/bin/perl.

      So I found the following:

      This does not work

      /usr/bin/perl < app.pl

      This works!

      /opt/local/bin/perl < app.pl

      My Mac is rather old and I have messed around with it on numerous occasions. Both versions appear to be v5.8.8.

      So I cannot explain what is broken, but at least my little app works now.

      Mark

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://788999]
Approved by holli
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others musing on the Monastery: (5)
As of 2024-04-19 21:11 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found