Solved

MacOS Perl is confused about its libraries

Posted on 2011-09-18
7
757 Views
Last Modified: 2012-05-12
I've been debugging an issue with Perl that is driving me nuts. It has to do with the GD and ImageMagick libraries.
Depending on which perl I run I get access to GD or ImageMagick but never both! I'd like to have one Perl that can access both.
I installed GD using CPAN and ImageMagick via macports.

Included is the code that fails
included are finds for both libraries
and perl -V for both as well

if I run /usr/bin/perl I get this error:

Can't locate Image/Magick.pm in @INC (@INC contains: /opt/local/lib /Library/Perl/5.12/CGI /Library/Perl/5.12/Apache /Library/CitrusPerl/i32/5-12/vendor/lib /Library/Perl/5.12/darwin-thread-multi-2level /sw/lib/perl5 /sw/lib/perl5/darwin /Library/Perl/5.12/darwin-thread-multi-2level /Library/Perl/5.12 /Network/Library/Perl/5.12/darwin-thread-multi-2level /Network/Library/Perl/5.12 /Library/Perl/Updates/5.12.3/darwin-thread-multi-2level /Library/Perl/Updates/5.12.3 /System/Library/Perl/5.12/darwin-thread-multi-2level /System/Library/Perl/5.12 /System/Library/Perl/Extras/5.12/darwin-thread-multi-2level /System/Library/Perl/Extras/5.12 .) at ./unzip-tag.pl line 17.

if I run /opt/local/bin/perl I get this error:

Can't locate GD.pm in @INC (@INC contains: /opt/local/lib /Library/Perl/5.12/CGI /Library/Perl/5.12/Apache /Library/CitrusPerl/i32/5-12/vendor/lib /Library/Perl/5.12/darwin-thread-multi-2level /sw/lib/perl5 /sw/lib/perl5/darwin /opt/local/lib/perl5/site_perl/5.12.3/darwin-multi-2level /opt/local/lib/perl5/site_perl/5.12.3 /opt/local/lib/perl5/vendor_perl/5.12.3/darwin-multi-2level /opt/local/lib/perl5/vendor_perl/5.12.3 /opt/local/lib/perl5/5.12.3/darwin-multi-2level /opt/local/lib/perl5/5.12.3 /opt/local/lib/perl5/site_perl /opt/local/lib/perl5/vendor_perl .) at ./unzip-tag.pl line 15.

HELP stop the insanity!!
#!/usr/bin/perl -W
#!/opt/local/bin/perl -W


###########################################
#

#use lib '/Library/CitrusPerl/i32/5-12/vendor/lib';
use lib '/opt/local/lib /Library/Perl/5.12/CGI /Library/Perl/5.12/Apache /Library/CitrusPerl/i32/5-12/vendor/lib /Library/Perl/5.12/darwin-thread-multi-2level';

use Env qw(PATH HOME TERM);

$useGD="no";
if ( $useGD eq "yes" ) {
	use GD;
} else {
	use Image::Magick;
};

Open in new window

# find /usr/local /Library/Perl/ -name "GD.pm" -print
/Library/Perl//5.12/darwin-thread-multi-2level/GD.pm

# find /usr/local /Library/Perl/ -name "*agick.pm" -print
/Library/Perl//5.12/Apache/Image/Magick.pm
/Library/Perl//5.12/Apache/ImageMagick.pm
/Library/Perl//5.12/Apache/Magick.pm
/Library/Perl//5.12/CGI/ImageMagick.pm

Open in new window

# /opt/local/bin/perl -V
Summary of my perl5 (revision 5 version 12 subversion 3) configuration:
   
  Platform:
    osname=darwin, osvers=11.1.0, archname=darwin-multi-2level
    uname='darwin imac.home 11.1.0 darwin kernel version 11.1.0: tue jul 26 16:07:11 pdt 2011; root:xnu-1699.22.81~1release_x86_64 x86_64 '
    config_args='-D inc_version_list=5.12.2/darwin-multi-2level 5.12.2 5.12.1/darwin-multi-2level 5.12.1 5.12.0/darwin-multi-2level 5.12.0 -des -Dprefix=/opt/local -Dscriptdir=/opt/local/bin -Dcppflags=-I/opt/local/include -Dccflags=-pipe -O2 -arch x86_64 -Dldflags=-L/opt/local/lib -arch x86_64 -Dvendorprefix=/opt/local -Dusemultiplicity=y -D cc=/Developer/usr/bin/llvm-gcc-4.2 -D ld=/Developer/usr/bin/llvm-gcc-4.2 -D man1ext=1pm -D man3ext=3pm -D man1dir=/opt/local/share/man/man1p -D man3dir=/opt/local/share/man/man3p -D siteman1dir=/opt/local/share/man/man1 -D siteman3dir=/opt/local/share/man/man3 -D vendorman1dir=/opt/local/share/man/man1 -D vendorman3dir=/opt/local/share/man/man3 -D pager=/usr/bin/less -sR'
    hint=recommended, useposix=true, d_sigaction=define
    useithreads=undef, usemultiplicity=define
    useperlio=define, d_sfio=undef, uselargefiles=define, usesocks=undef
    use64bitint=define, use64bitall=define, uselongdouble=undef
    usemymalloc=n, bincompat5005=undef
  Compiler:
    cc='/Developer/usr/bin/llvm-gcc-4.2', ccflags ='-pipe -O2 -arch x86_64 -fno-common -DPERL_DARWIN -I/opt/local/include -no-cpp-precomp -fno-strict-aliasing -fstack-protector -I/opt/local/include',
    optimize='-O3',
    cppflags='-I/opt/local/include -no-cpp-precomp -pipe -O2 -arch x86_64 -fno-common -DPERL_DARWIN -I/opt/local/include -no-cpp-precomp -fno-strict-aliasing -fstack-protector -I/opt/local/include'
    ccversion='', gccversion='4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2335.15.00)', gccosandvers=''
    intsize=4, longsize=8, ptrsize=8, doublesize=8, byteorder=12345678
    d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=16
    ivtype='long', ivsize=8, nvtype='double', nvsize=8, Off_t='off_t', lseeksize=8
    alignbytes=8, prototype=define
  Linker and Libraries:
    ld='env MACOSX_DEPLOYMENT_TARGET=10.3 /Developer/usr/bin/llvm-gcc-4.2', ldflags ='-L/opt/local/lib -arch x86_64 -fstack-protector'
    libpth=/opt/local/lib /usr/lib
    libs=-lgdbm -ldbm -ldl -lm -lutil -lc
    perllibs=-ldl -lm -lutil -lc
    libc=, so=dylib, useshrplib=false, libperl=libperl.a
    gnulibc_version=''
  Dynamic Linking:
    dlsrc=dl_dlopen.xs, dlext=bundle, d_dlsymun=undef, ccdlflags=' '
    cccdlflags=' ', lddlflags='-L/opt/local/lib -arch x86_64 -bundle -undefined dynamic_lookup -fstack-protector'


Characteristics of this binary (from libperl): 
  Compile-time options: MULTIPLICITY PERL_DONT_CREATE_GVSV
                        PERL_IMPLICIT_CONTEXT PERL_MALLOC_WRAP USE_64_BIT_ALL
                        USE_64_BIT_INT USE_LARGE_FILES USE_PERLIO
                        USE_PERL_ATOF
  Built under darwin
  Compiled at Sep 11 2011 00:07:00
  @INC:
    /opt/local/lib/perl5/site_perl/5.12.3/darwin-multi-2level
    /opt/local/lib/perl5/site_perl/5.12.3
    /opt/local/lib/perl5/vendor_perl/5.12.3/darwin-multi-2level
    /opt/local/lib/perl5/vendor_perl/5.12.3
    /opt/local/lib/perl5/5.12.3/darwin-multi-2level
    /opt/local/lib/perl5/5.12.3
    /opt/local/lib/perl5/site_perl
    /opt/local/lib/perl5/vendor_perl
    .



# /usr/bin/perl -V
Summary of my perl5 (revision 5 version 12 subversion 3) configuration:
   
  Platform:
    osname=darwin, osvers=11.0, archname=darwin-thread-multi-2level
    uname='darwin fifth.apple.com 11.0 darwin kernel version 11.0.0: sun may 29 13:02:55 pdt 2011; root:xnu-1699.22.44~4release_x86_64 x86_64 '
    config_args='-ds -e -Dprefix=/usr -Dccflags=-g  -pipe  -Dldflags= -Dman3ext=3pm -Duseithreads -Duseshrplib -Dinc_version_list=none -Dcc=llvm-gcc-4.2'
    hint=recommended, useposix=true, d_sigaction=define
    useithreads=define, usemultiplicity=define
    useperlio=define, d_sfio=undef, uselargefiles=define, usesocks=undef
    use64bitint=define, use64bitall=define, uselongdouble=undef
    usemymalloc=n, bincompat5005=undef
  Compiler:
    cc='llvm-gcc-4.2', ccflags ='-arch x86_64 -arch i386 -g -pipe -fno-common -DPERL_DARWIN -fno-strict-aliasing -fstack-protector -I/usr/local/include',
    optimize='-Os',
    cppflags='-g -pipe -fno-common -DPERL_DARWIN -fno-strict-aliasing -fstack-protector -I/usr/local/include'
    ccversion='', gccversion='4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2335.15.00)', gccosandvers=''
    intsize=4, longsize=8, ptrsize=8, doublesize=8, byteorder=12345678
    d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=16
    ivtype='long', ivsize=8, nvtype='double', nvsize=8, Off_t='off_t', lseeksize=8
    alignbytes=8, prototype=define
  Linker and Libraries:
    ld='llvm-gcc-4.2 -mmacosx-version-min=10.7', ldflags ='-arch x86_64 -arch i386 -fstack-protector -L/usr/local/lib'
    libpth=/usr/local/lib /usr/lib
    libs=-ldbm -ldl -lm -lutil -lc
    perllibs=-ldl -lm -lutil -lc
    libc=, so=dylib, useshrplib=true, libperl=libperl.dylib
    gnulibc_version=''
  Dynamic Linking:
    dlsrc=dl_dlopen.xs, dlext=bundle, d_dlsymun=undef, ccdlflags=' '
    cccdlflags=' ', lddlflags='-arch x86_64 -arch i386 -bundle -undefined dynamic_lookup -L/usr/local/lib -fstack-protector'


Characteristics of this binary (from libperl): 
  Compile-time options: MULTIPLICITY PERL_DONT_CREATE_GVSV
                        PERL_IMPLICIT_CONTEXT PERL_MALLOC_WRAP USE_64_BIT_ALL
                        USE_64_BIT_INT USE_ITHREADS USE_LARGE_FILES
                        USE_PERLIO USE_PERL_ATOF USE_REENTRANT_API
  Locally applied patches:
	/Library/Perl/Updates/<version> comes before system perl directories
	installprivlib and installarchlib points to the Updates directory
  Built under darwin
  Compiled at Jun 13 2011 14:45:31
  @INC:
    /Library/Perl/5.12/darwin-thread-multi-2level
    /Library/Perl/5.12
    /Network/Library/Perl/5.12/darwin-thread-multi-2level
    /Network/Library/Perl/5.12
    /Library/Perl/Updates/5.12.3/darwin-thread-multi-2level
    /Library/Perl/Updates/5.12.3
    /System/Library/Perl/5.12/darwin-thread-multi-2level
    /System/Library/Perl/5.12
    /System/Library/Perl/Extras/5.12/darwin-thread-multi-2level
    /System/Library/Perl/Extras/5.12
    .

Open in new window

0
Comment
Question by:bs98909
  • 4
  • 3
7 Comments
 
LVL 28

Expert Comment

by:FishMonger
ID: 36556508
All use statements are seen and executed during compilation even if they are in a conditional block.  You need to use a require statement instead of a use statement.

You also should remove the -W switch and add the warnings and strict pragmas, which should be in every script you write.
0
 

Author Comment

by:bs98909
ID: 36556639
Well yes that is fine that the conditional truly doesn't matter since I have to comment out the use block.

And removing the -w and using strict and warnings returned the same results. Not that I expected other wise.
0
 
LVL 28

Expert Comment

by:FishMonger
ID: 36556650
Are you saying this is what you've tried and it gives the same results?

#!/usr/bin/perl
#!/opt/local/bin/perl

use strict;
use warnings;

###########################################
#

#use lib '/Library/CitrusPerl/i32/5-12/vendor/lib';
use lib '/opt/local/lib /Library/Perl/5.12/CGI /Library/Perl/5.12/Apache /Library/CitrusPerl/i32/5-12/vendor/lib /Library/Perl/5.12/darwin-thread-multi-2level';

use Env qw(PATH HOME TERM);

my $useGD="no";
if ( $useGD eq "yes" ) {
	require GD;
} else {
	require Image::Magick;
};

Open in new window

0
What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

 

Author Comment

by:bs98909
ID: 36556790
no -- I stil had the "use" -- but now I changed the "use" to "require" and I still get:

Can't locate Image/Magick.pm in @INC (@INC contains: /opt/local/lib /Library/Perl/5.12/CGI /Library/Perl/5.12/Apache /Library/CitrusPerl/i32/5-12/vendor/lib /Library/Perl/5.12/darwin-thread-multi-2level /opt/local/lib/perl5/site_perl/5.12.3/darwin-multi-2level/Image /Library/Perl/5.12/darwin-thread-multi-2level /Library/Perl/5.12 /Network/Library/Perl/5.12/darwin-thread-multi-2level /Network/Library/Perl/5.12 /Library/Perl/Updates/5.12.3/darwin-thread-multi-2level /Library/Perl/Updates/5.12.3 /System/Library/Perl/5.12/darwin-thread-multi-2level /System/Library/Perl/5.12 /System/Library/Perl/Extras/5.12/darwin-thread-multi-2level /System/Library/Perl/Extras/5.12 .) at Untitled 4.pl line 24.
0
 
LVL 28

Expert Comment

by:FishMonger
ID: 36556809
It appears to me that Image::Magic wasn't properly installed.

This appears to be an odd path and is not in your @INC path: /Library/Perl//5.12/Apache/
Note the double // forward slashes.
0
 
LVL 28

Accepted Solution

by:
FishMonger earned 125 total points
ID: 36556852
Another issue you have is with the 'use lib' statement.  The lib pragma expects a list of paths, not a string of paths.  Change that line to:
use lib qw(/opt/local/lib /Library/Perl/5.12/CGI /Library/Perl/5.12/Apache /Library/CitrusPerl/i32/5-12/vendor/lib /Library/Perl/5.12/darwin-thread-multi-2level);

Open in new window

0
 

Author Closing Comment

by:bs98909
ID: 36556899
AH that was it!! I was passing in the string and not a list!

Working much better now!

Thank you
0

Featured Post

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

Information security is a multi-billion dollar industry. Just as lucrative is the black market industry which trades stolen identities, credit card numbers and software exploits all over the world. Nothing is hack-proof. The best one can do is make …
In the distant past (last year) I hacked together a little toy that would allow a couple of Manager types to query, preview, and extract data from a number of MongoDB instances, to their tool of choice: Excel (http://dilbert.com/strips/comic/2007-08…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now