Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Mac::Carbon et.c on Mac OS X 10.8

by kwalker (Novice)
on Feb 22, 2013 at 19:01 UTC ( #1020210=perlquestion: print w/ replies, xml ) Need Help??
kwalker has asked for the wisdom of the Perl Monks concerning the following question:

I just upgraded from Mac OS X 10.6 to 10.8. I find that the version of perl which ships with 10.8 has Mac::Glue, Mac::Carbon etc. preinstalled, but it doesn't seem to be functional due to what I suspect are 32/64-bit architecture issues:

[kw|~] perl5.12 -ce 'use Mac::Glue' Can't load '/System/Library/Perl/Extras/5.12/darwin-thread-multi-2leve +l/auto/MacPerl/MacPerl.bundle' for module MacPerl: dlopen(/System/Lib +rary/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/M +acPerl/MacPerl.bundle: mach-o, but wrong architecture at /System/Libr +ary/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.

I tried "export VERSIONER_PERL_PREFER_32_BIT=yes" but that didn't seem to make any difference. Is there any way to make Mac::Glue et al work with the built-in perl, or will I need to build my own perl? If the latter, what are the best compiler and linker flags to use?

Comment on Mac::Carbon et.c on Mac OS X 10.8
Download Code
Re: Mac::Carbon et.c on Mac OS X 10.8
by Anonymous Monk on Feb 22, 2013 at 19:55 UTC

    etc. preinstalled, but it doesn't seem to be functional

    please complain to whomever pre-installed it, packaged it

    or, compile it yourself, cpan -i Mac::Glue Mac::Carbon

Re: Mac::Carbon et.c on Mac OS X 10.8
by luis.roca (Deacon) on Feb 22, 2013 at 23:18 UTC

    I honestly don't know why they shipped these modules with Mountain Lion. As far as I can tell, they have not been updated for a few years (Possibly since Tiger) and were not included in the last few versions of OSX for what I can assume are those very reasons you mentioned. At least with Mac::Carbon the documentation states there are significant portions of the Carbon API that are unavailable to programs on Mac OSX (See 64-Bit Perl section). Quickly looking at Mac::Glue seems to indicate some conflicts as well.

    If you're looking to work with the Finder and other applications on the Mac, I would stick with AppleScript and combine it with Perl shell scripts. You can call one from the other. They pair well together from what I remember. Check out the Mac Developer library on how http://developer.apple.com/library/mac/#technotes/tn2065/_index.html as well as Oreilly's AppleScript The Definitive Guide has some, dated, but good examples if you sift through them. If you'll be working often this way, it may be worth a few bucks for you to get the excellent ScriptDebugger which takes a lot of the headaches out of grokking each software's particular flavor of AppleScript.

    I don't want to discourage you from a separate install of Perl. That's not a bad idea and often recommended but I don't think it will help you with this particular issue. To download and maintain a separate install on the Mac, I use Macports.

    Good luck :)

    "...the adversities born of well-placed thoughts should be considered mercies rather than misfortunes." Don Quixote

      Thanks, that's helpful.

      Before posting here I had already tried rebuilding Mac::Glue (as suggested in the first response to my original question), but without any luck. I was planning on next building my own perl, but then I began to suspect that the problem was more fundamental and could not be fixed by tweaking the build parameters.

      Perl (v5.12.4) claims to be bi-architectural:

      [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 x +86_64
      The module I want to use is 32-bit i386:
      [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-2le +vel/auto/MacPerl/MacPerl.bundle is architecture: i386
      But things fail anyway:
      [kw|~] perl -ce 'use Mac::Glue' Can't load '/System/Library/Perl/Extras/5.12/darwin-thread-multi-2leve +l/auto/MacPerl/MacPerl.bundle' for module MacPerl: dlopen(/System/Lib +rary/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/M +acPerl/MacPerl.bundle: mach-o, but wrong architecture at /System/Libr +ary/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.
      I'm guessing that I'm out of luck, since the OS is 64-bit and Mac::Glue will only build as 32-bit (since it depends on the Carbon API). But I'm a novice on these architecture compatibility issues, so if someone wants to authoritatively confirm that I'm out of luck I would appreciate it.

        The short answer would be no.

        From perlmacosx (specifically that last paragraph)

        Support for 64-bit addressing is experimental: some aspects of Perl ma +y be omitted or buggy. Note the messages output by Configure for fur +ther information. Please use "perlbug" to submit a problem report in th +e event that you encounter difficulties. When building 64-bit modules, it is your responsiblity to ensure t +hat linked external libraries and frameworks provide 64-bit support: i +f they do not, module building may appear to succeed, but attempts to use + the module will result in run-time dynamic linking errors, and subsequ +ent test failures. You can use "file" to discover the architectures supported by a library: $ file libgdbm.3.0.0.dylib libgdbm.3.0.0.dylib: Mach-O fat file with 2 architectures libgdbm.3.0.0.dylib (for architecture ppc): Mach-O dynami +cally linked shared library ppc libgdbm.3.0.0.dylib (for architecture ppc64): Mach-O 64-bit + dynamically linked shared library ppc64 Note that this issue precludes the building of many Macintosh-spec +ific CPAN modules ("Mac::*"), as the required Apple frameworks do not p +rovide PPC64 support. Similarly, downloads from Fink or Darwinports are unlikely to provide 64-bit support; the libraries must be rebuilt +from source with the appropriate compiler and linker flags. For further information, see Apple's *64-Bit Transition Guide* at <http://developer.apple.com/documentation/Darwin/Conceptual/64bitP +orting /index.html>.

        That last link no longer works and redirects you to a menu. Here's the updated page if you're interested: http://developer.apple.com/library/mac/#documentation/Darwin/Conceptual/64bitPorting/intro/intro.html


        "...the adversities born of well-placed thoughts should be considered mercies rather than misfortunes." Don Quixote
Re: Mac::Carbon et.c on Mac OS X 10.8
by kwalker (Novice) on Feb 24, 2013 at 00:11 UTC

    I am happy and surprised to report that I found a solution to the problem: use the MacOSX 'arch' command.

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

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (6)
As of 2014-09-02 01:07 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite cookbook is:










    Results (18 votes), past polls