Link to home
Start Free TrialLog in
Avatar of Brian S
Brian SFlag for United States of America

asked on

MacOS Perl is confused about its libraries

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

Avatar of FishMonger
FishMonger
Flag of United States of America image

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.
Avatar of Brian S

ASKER

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.
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

Avatar of Brian S

ASKER

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.
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.
ASKER CERTIFIED SOLUTION
Avatar of FishMonger
FishMonger
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Brian S

ASKER

AH that was it!! I was passing in the string and not a list!

Working much better now!

Thank you