in reply to Re^4: Math::GMP won't install on Darwin
in thread Math::GMP won't install on Darwin

OK, so here's what I did.

1. Downloaded, configured and compiled libgmp 4.2.1 using gcc 4.0.1 (the latest version from XCode).

2. "make check" on libgmp. No errors.

3. Installed libgmp (make install), again, no errors.

4. Tried to install Math::GMP using CPAN. This fails:

Checking if your kit is complete... Looks good Writing Makefile for Math::GMP cp lib/Math/GMP.pm blib/lib/Math/GMP.pm AutoSplitting blib/lib/Math/GMP.pm (blib/lib/auto/Math/GMP) /usr/local/bin/perl /usr/local/lib/perl5/5.8.8/ExtUtils/xsubpp -typem +ap /usr/local/lib/perl5/5.8.8/ExtUtils/typemap -typemap typemap GMP. +xs > GMP.xsc && mv GMP.xsc GMP.c gcc -c -fno-common -DPERL_DARWIN -no-cpp-precomp -fno-strict-aliasin +g -pipe -Wdeclaration-after-statement -I/usr/local/include -I/opt/loc +al/include -O3 -DVERSION=\"2.04\" -DXS_VERSION=\"2.04\" "-I/usr/lo +cal/lib/perl5/5.8.8/darwin-2level/CORE" GMP.c Running Mkbootstrap for Math::GMP () chmod 644 GMP.bs rm -f blib/arch/auto/Math/GMP/GMP.bundle env MACOSX_DEPLOYMENT_TARGET=10.3 cc -bundle -undefined dynamic_looku +p -L/usr/local/lib -L/opt/local/lib GMP.o -o blib/arch/auto/Math/GMP +/GMP.bundle \ -lgmp \ /usr/bin/ld: /usr/local/lib/libgmp.a(mode1o.o) has local relocation en +tries in non-writable section (__TEXT,__text) collect2: ld returned 1 exit status make: *** [blib/arch/auto/Math/GMP/GMP.bundle] Error 1 /usr/bin/make -- NOT OK Running make test Can't test without successful make Running make install make had returned bad status, install seems impossible Failed during this command: CHIPT/Math-GMP-2.04.tar.gz : make NO

5. Back to libgmp, make distclean

6. Switch gcc to version 3.3

7. Repeat configure/make cycle (no errors)

8. make check (no errors)

9. Tried to install Math::GMP. Same result as above.

Please feel free to contact me if you need any further information. I'll be glad to help.

Thanks,

Peter.

Replies are listed 'Best First'.
Re^6: Math::GMP won't install on Darwin
by syphilis (Archbishop) on Jul 15, 2006 at 01:48 UTC
    There are some ideas on things to try in the thread called "how do I force PIC code in libgmp.a on MacOSX (Intel)...?" beginning at http://swox.com/list-archives/gmp-bugs/2006-April/000341.html. Unfortunately it doesn't seem to resolve the problem - beyond the suggestion that you revert to GMP-4.1.4 (which should be quite adequate for your needs ... assuming that solution does, in fact, work).

    I'm puzzled by the reference to 'modelo.o' (which I can't find anywhere in any of my GMP builds), and by the 'cc' (as opposed to 'gcc') call you report just before the failure occurs. I wonder whether the 'cc' call might have something to do with the error, though the thread I referred to above suggests that it has more to do with the 'bundle' switch ... and I have no idea what that switch does, or why it is being invoked.

    My only other idea is to build GMP as a shared library (./configure --disable-static --enable-shared) .... and, if linking to the import lib still produces the same error, then amend the Math::GMP source so that it links directly to the GMP '.so'. (I have no idea whether that will help in this instance ... it's just something I would try.)

    Cheers,
    Rob

      Hi Rob,

      thanks for your suggestions. I tried both building libgmp as a shared library (which didn't solve the problem) and reverting to libgmp 4.1.4 (which did).

      The reference to cc shouldn't be a problem, as /usr/bin/cc is a logical link to /usr/bin/gcc-4.0 (as is /usr/bin/gcc).

      The -bundle switch tells ld to create a bundle file:

      -bundle Produce a Mach-O bundle format file. The headers are pl +aced in the first segment. All sections are placed in their pro +per seg- ments and they are padded to the segment alignment. Thi +s has a file type of MH_BUNDLE.

      Thank you very much for your helpful suggestions!

      Regards,

        Peter.

        I tried both building libgmp as a shared library (which didn't solve the problem) and reverting to libgmp 4.1.4 (which did).

        Thanks for the feedback.

        Did you try forcing Math::GMP to link directly to the shared library (rather than linking to the import library) ? I gave that a fair chance of working ... on a hunch, more than anything else :-)

        Mind you, whilst I know that gcc can link directly to shared libraries on Win32 and Linux, I have no such knowledge regarding gcc on Macs. And, of course I've got no right to press you like this for details ... so please feel free to ignore.

        Cheers,
        Rob