jkeenan1 has asked for the wisdom of the Perl Monks concerning the following question:

Over the past few years a number of Perlmonks threads have dealt with problems in installing the Math::GMP distribution from CPAN. I have tried to install Math::GMP on two different OSes in the past two days: Ubuntu Linux and Darwin Mac OS X 10.3. In each case, when the 'cpan' shell got to the 'perl Makefile.PL' step, the following warning was displayed:

CPAN.pm: Going to build C/CH/CHIPT/Math-GMP-2.04.tar.gz Checking if your kit is complete... Looks good ----> Note (probably harmless): No library found for -lgmp Writing Makefile for Math::GMP

This has to be one of the most misleading messages I've ever seen. In each case it signified the absence of the 'libgmp3' library. The 'cpan' process continued as follows:

GMP.xs:4:17: gmp.h: No such file or directory GMP.c: In function `XS_Math__GMP_new_from_scalar': GMP.c:99: error: `mpz_t' undeclared (first use in this function) GMP.c:99: error: (Each undeclared identifier is reported only once GMP.c:99: error: for each function it appears in.) GMP.c:99: error: `RETVAL' undeclared (first use in this function) GMP.c: In function `XS_Math__GMP_new_from_scalar_with_base': GMP.c:121: error: `mpz_t' undeclared (first use in this function) GMP.c:121: error: `RETVAL' undeclared (first use in this function) [snip 100+ more lines of error messages] make: *** [GMP.o] 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

In the case of Ubuntu Linux, I was able to proceed once I had installed the Debian libgmp3-dev library.

There being no equivalent library that I knew of for Darwin, I had to compile libgmp from source -- which, it turned out, required that I compile libtools from source as well.

45 minutes later (!) I was ready to try to install Math-GMP again. But I then got this error message when I called make:

ld: /usr/local/lib/libgmp.a(mode1o.o) has local relocation entries i +n non-writable section (__TEXT,__text)

Has anyone been able to achieve better results trying to install Math::GMP on Darwin? (I should add that I'm really only interested in this because it's a prerequisite for Net::SSH::Perl.)

My Darwin configuration:

On Darwin: Perl 5.8.7 Summary of my perl5 (revision 5 version 8 subversion 7) configuration: Platform: osname=darwin, osvers=7.9.0, archname=darwin-2level uname='darwin macintosh.local 7.9.0 darwin kernel version 7.9.0: wed mar 30 20:11:17 pst 2005; root:xnuxnu-517.12.7.obj~1release_ppc power macintosh powerpc ' config_args='-de' hint=recommended, useposix=true, d_sigaction=define usethreads=undef use5005threads=undef useithreads=undef usemultiplicity=undef useperlio=define d_sfio=undef uselargefiles=define usesocks=undef use64bitint=undef use64bitall=undef uselongdouble=undef usemymalloc=n, bincompat5005=undef Compiler: cc='cc', ccflags ='-fno-common -DPERL_DARWIN -no-cpp-precomp -fno-strict-aliasing -pipe -I/usr/local/include', optimize='-Os', cppflags='-no-cpp-precomp -fno-common -DPERL_DARWIN -no-cpp-precomp -fno-strict-aliasing -pipe -I/usr/local/include' ccversion='', gccversion='3.3 20030304 (Apple Computer, Inc. build 1495)', gccosandvers='' intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=4321 d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=8 ivtype='long', ivsize=4, nvtype='double', nvsize=8, Off_t='off_t', lseeksize=8 alignbytes=8, prototype=define Linker and Libraries: ld='env MACOSX_DEPLOYMENT_TARGET=10.3 cc', ldflags =' -L/usr/local/lib' libpth=/usr/local/lib /lib /usr/lib libs=-ldbm -ldl -lm -lc perllibs=-ldl -lm -lc libc=/usr/lib/libc.dylib, so=dylib, useshrplib=false, libperl=libperl.a gnulibc_version='' Dynamic Linking: dlsrc=dl_dyld.xs, dlext=bundle, d_dlsymun=undef, ccdlflags=' ' cccdlflags=' ', lddlflags=' -bundle -undefined dynamic_lookup -L/usr/local/lib' Characteristics of this binary (from libperl): Compile-time options: USE_LARGE_FILES Built under darwin Compiled at Oct 24 2005 21:19:21

Jim Keenan

Replies are listed 'Best First'.
Re: Math::GMP won't install on Darwin
by jaldhar (Vicar) on Apr 15, 2006 at 00:57 UTC
    1. Did you know Math::GMP is already in Ubuntu as the package libmath-gmp-perl? For that matter Net::SSH is libnet-ssh-perl.
    2. I think your Darwin travails are due to an older version of gcc miscompiling libgmp3. Can you try with 3.4 or higher?

    --
    જલધર

      jaldhar wrote:

      Did you know Math::GMP is already in Ubuntu as the package libmath-gmp-perl? For that matter Net::SSH is libnet-ssh-perl.

      No, I did not. However, while I've tried to consistently use ubuntu and debian packages for most additions, Perl I've installed from source (in order to get the most recent version, which is never available in Debian stable) and CPAN modules I always first try to install with the cpan shell.

      I think your Darwin travails are due to an older version of gcc miscompiling libgmp3. Can you try with 3.4 or higher?

      I'll try to give that a shot.

      Jim Keenan
Re: Math::GMP won't install on Darwin
by bowei_99 (Friar) on Apr 17, 2006 at 05:59 UTC
    Hm, I'm also running MacOS 10.3, with the same version of gcc, and I get the exact same error.

    If it is in fact a gcc upgrade that's necessary, that version of gcc (3.3 20030304) seems to be the latest one that's available from http://developer.apple.com for 10.3. There are some more recent downloads (Xcode Tools 2.1 and 2.2) for MacOS 10.4, but I don't know if you want to shell out more money for 10.4.

    I suppose you could email the maintainer of Math::GMP about it. Then again, I figure he must have already seen the bug report on rt.cpan.org ....

    Update: I poked around on the tests for Math::GMP, and found at least this one instance of gcc (3.3.3 FreeBSD 20031106) that's about the same age as the one on the Mac, and it passed. Interestingly enough, there's this case that passed, but using gcc 3.0.3. Although it's Solaris, my feeling is that it's not the version of gcc that's the problem ...

    Update 2: I also think it couldn't be miscompiling libgmp, as I did a make check (as emphasized on the download site), and I still got the same thing. However, looking at the website, I see something else. This is from the GNU MP Bignum library (libgmp) site:

    GMP is very often miscompiled! We are seeing ever increasing problems with mis-compilations of the GMP code. Please never use your newly compiled libgmp.a or libgmp.so without first running make check. If it doesn't complete without errors, don't trust the library, and please report this as a bug to the gmp-bugs@swox.com list, so that we can investigate it and make sure the bug is indeed in the compiler. (The compilers that cause problems are HP's unbundled compilers and GCC, in particular Apple's GCC releases. It has come to the point where a compiler should be assumed to miscompile GMP.)

    I think that last note about 'Apple's gcc releases may be the answer... it seems that make check may find no problems, when there actually really are. I dunno, maybe post something on their forum, asking when it might be fixed..

    -- Burvil

      This is what I've done over the past several days:

      1. I upgraded to the most recent version of gcc which is expected to work on Mac OS X 10.3.9: gcc-4.0.3

      This process, incidentally, took hours. I went do dinner and then to bed and it was still running! Did a lot of work with gcj, which I guess has to do with Java.

      2. Tonight I reinstalled gmp-4.2. It went much faster than previously. As per the instructions cited by bowei_99 above, I performed make check after doing make install. All tests passed.

      3. I attempted to reinstall Math-GMP via the cpan shell. I got the same error as before:

      CPAN.pm: Going to build C/CH/CHIPT/Math-GMP-2.04.tar.gz 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.7/ExtUtils/xsubpp -typem +ap /usr/local/lib/perl5/5.8.7/ExtUtils/typemap -typemap typemap GMP. +xs > GMP.xsc && mv GMP.xsc GMP.c cc -c -fno-common -DPERL_DARWIN -no-cpp-precomp -fno-strict-aliasing + -pipe -I/usr/local/include -Os -DVERSION=\"2.04\" -DXS_VERSION=\"2 +.04\" "-I/usr/local/lib/perl5/5.8.7/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 GMP.o -o blib/arch/auto/Math/GMP/GMP.bundle \ -lgmp \ ld: /usr/local/lib/libgmp.a(mode1o.o) has local relocation entries in +non-writable section (__TEXT,__text) 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

      Any more ideas? Thanks.

      Jim Keenan
        Are there any newer insights about this issue? I tried gcc 3.3 and gcc 4.0 from the latest XCode 2.3 release, but both failed in exactly the same way. I need to build Math::GMP for a demo installation of a project requiring Net::SSH, and currently I'm stuck. Thanks in advance, Peter Eckel.
Re: Math::GMP won't install on Darwin
by gam3 (Curate) on Apr 16, 2006 at 04:22 UTC
    Math-GMP requires that the gnu gmp header files be installed. On debian:
       apt-get install libgmp3-dev
    
    should do the trick.

    debian also has libmath-gmp-perl but as you point out is not keep up to date.

    -- gam3
    A picture is worth a thousand words, but takes 200K.
      As noted in my original post, I did install libgmp3-dev on Ubuntu and was able to proceed from there to install Math::GMP. The problem is on Darwin.

      Jim Keenan