How do I make OS X 10.6 compile JSON::XS as 32-bit instead of 64-bit?
I compiled Perl 5.10.1 under OS X 10.5. It was compiled as a 32-bit program. I have since upgraded to OS X 10.6. My version of Perl 5.10.1 continues to work fine, but I just tried to compile JSON::XS and got errors like the following:
Can't load '/Users/cowens/.cpan/build/JSON-XS-2.26-clO6XX/blib/arch/auto/JSON/XS/XS.bundle' for module JSON::XS: dlopen(/Users/cowens/.cpan/build/JSON-XS-2.26-clO6XX/blib/arch/auto/JSON/XS/XS.bundle, 2): no suitable image found. Did find: /Users/cowens/.cpan/build/JSON-XS-2.26-clO6XX/blib/arch/auto/JSON/XS/XS.bundle: mach-o, but wrong architecture at /Users/cowens/local/lib/perl5/5.10.1/darwin-thread-multi-2level/DynaLoader.pm line 204.
A quick look at /Users/cowens/.cpan/build/JSON-XS-2.26-clO6XX/blib/arch/auto/JSON/XS/XS.bundle
shows th开发者_C百科at it is indeed a 64-bit library:
/Users/cowens/.cpan/build/JSON-XS-2.26-clO6XX/blib/arch/auto/JSON/XS/XS.bundle: Mach-O 64-bit bundle x86_64
Since this is most likely the culprit, I want to try compiling the module as 32-bit. I assume there is some environment variable (like CCFLAGS
) I can set to force it to compile as a 32-bit library instead of a 64-bit library.
The alternative seems to be to recompile Perl and all of my modules (something I am not sure I want to do).
If your Perl is installed in /usr/perl/v5.10.1
, then try looking in the file /usr/perl/v5.10.1/lib/5.10.1/darwin-2level/Config.pm
. There should be an entry for 'cc' in it; carefully (take a backup copy first) modify that from 'cc' to 'cc -m32'. Try rebuilding JSON::XS. What this does is change Perl's view of its configuration, and the 'cc -m32' enforces a 32-bit build.
Make sure your system perl isnt 64bit, and that your copy of perl isn't loading that 64bit perls Config. You can check by dumping %INC
精彩评论