Take the 2-minute tour ×
Ask Different is a question and answer site for power users of Apple hardware and software. It's 100% free, no registration required.

I just upgraded from MacOSX 10.6 to 10.8. Many of my projects depend on Mac::Glue, Mac::Carbon and their ilk. Even though Mac::Glue comes bundled with MacOSX 10.8 perl, it doesn't seem to work:

[kw|~] perl -ce 'use Mac::Glue'
Can't load '/System/Library/Perl/Extras/5.12/darwin-thread-multi-2level/auto/MacPerl/MacPerl.bundle' for module MacPerl: dlopen(/System/Library/Perl/Extras/5.12/darwin-thread-multi-2level/auto/MacPerl/MacPerl.bundle, 1): no suitable image found.  Did find:
    /System/Library/Perl/Extras/5.12/darwin-thread-multi-2level/auto/MacPerl/MacPerl.bundle: mach-o, but wrong architecture at /System/Library/Perl/5.12/darwin-thread-multi-2level/DynaLoader.pm line 204.
 at /System/Library/Perl/Extras/5.12/Mac/Glue/Common.pm line 21
Compilation failed in require at /System/Library/Perl/Extras/5.12/Mac/Glue/Common.pm line 21.
BEGIN failed--compilation aborted at /System/Library/Perl/Extras/5.12/Mac/Glue/Common.pm line 21.
Compilation failed in require at /System/Library/Perl/Extras/5.12/Mac/Glue.pm line 7.
BEGIN failed--compilation aborted at /System/Library/Perl/Extras/5.12/Mac/Glue.pm line 7.
Compilation failed in require at -e line 1.
BEGIN failed--compilation aborted at -e line 1.

Mac::Glue is 32-bit:

[kw|~] lipo -info /System/Library/Perl/Extras/5.12/darwin-thread-multi-2level/auto/MacPerl/MacPerl.bundle
Non-fat file: /System/Library/Perl/Extras/5.12/darwin-thread-multi-2level/auto/MacPerl/MacPerl.bundle is architecture: i386

/usr/bin/perl claims to be compatible with that architecture:

[kw|~] file /usr/bin/perl
/usr/bin/perl: Mach-O universal binary with 2 architectures
/usr/bin/perl (for architecture i386):  Mach-O executable i386
/usr/bin/perl (for architecture x86_64):    Mach-O 64-bit executable x86_64

I'm running MacOSX 10.8.2, perl 5.12.4.

Does anyone have any idea how to fix this problem? If MacOSX is 64-bit, does that prevent perl from being compatible with 32-bit modules, despite its claim to be compatible with two architectures?

share|improve this question
add comment

2 Answers

I found a solution to the problem: use the MacOSX 'arch' command to force perl to run as 32-bit. (See also http://stackoverflow.com/questions/2088569/how-do-i-force-python-to-be-32-bit-on-snow-leopard-and-other-32-bit-64-bit-quest .)

[kw|~] arch -32 perl5.12 -ce 'use Mac::Glue'
-e syntax OK

Note that one needs the explicit "perl5.12" and not simply "perl", since (on MacOSX 10.8) /usr/bin/perl is a shell script which delegates to either /usr/bin/perl5.12 or /usr/bin/perl5.10.

share|improve this answer
add comment

Actually, there are two other ways to do it, if we refer to man perlmacosx :

  1. Use "defaults":

    % defaults write com.apple.versioner.perl Prefer-32-Bit -bool yes 
    
  2. Use the environment variable VERSIONER_PERL_PREFER_32_BIT set to "true", "yes" or 1

With either one, perl -ce 'use Mac::Glue' gets you: -e syntax OK

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.