I'd like to use gmp, mpfr, and mpfrcpp but am having difficulty
getting mpfr (and also mpfrcpp) to make check. I'm using a G5, and I
'sudo make install' everything so that the lib and include files end
up in /usr/local/include
and /usr/local/lib
I tried following the README and INSTALL instructions, but have gotten
various compiling errors at the make check stages of mpfr and of
mpfrcpp... including path
problems and problems with linking (Undefined symbols). I don't see
why as I've set the configure options for mpfr: --with-gmp=/usr/local
I'm wondering if anyone here has experience configuring, making, and
installing gmp and then mpfr on a mac (mpfrcpp would also be nice)
and,
if so, can you tell me what options you used to configure, make,
install,
whether anything tricky was needed.
machine: G5 powerpc, mac os x 10.4.10, gcc 4.0.1:
settings for gmp-4.2.1:
./configure --enable-cxx --with-pic
make
sudo make install
sudo cp *.h /usr/local/include/.
(not all header files that are needed by other packages get copied
over, so I did that manually)
mpfr-2.3.0:
./configure --with-gmp-build=/Users/michael/math/L/packages/gmp-4.2.1
--with-pic
make
sudo make install
note: I first tried to configure mpfr using --with-gmp=/usr/local,
but that produced a configure error:
"checking for valid BITS_PER_MP_LIMB and BYTES_PER_MP_LIMB... no
configure: error: BITS_PER_MP_LIMB or BYTES_PER_MP_LIMB are incorrect.
You probably need to change some of the GMP or MPFR compile options."
so I used my local build instead. Obviously, you would need to modify
the
path for --with-gmp-build.
I used --with-pic after coming on that advice via google (see below).
Without it I was getting a weird error when linkinbg mpfr:
"not allowed in slidable image"
mpfrcpp-1.4.1:
I was getting weird linking errors, but, on my G5, adding -m64
as a compile option worked. I did this in two files, first in
mpfrcpp-1.4.1/src/mpfrcpp/Makefile:
$(CC) -m64 initialization/*.cpp $(OPTIONS)
and also in mpfrcpp-1.4.1/Makefile
OPTIONS = -lmpfrcpp -lgmp -lmpfr --pedantic --std=c++98 -Wall -m64
and also:
g++ -m64 -c $(testdir)separate_compilation_a.cpp > $(logfile)
g++ -m64 -c $(testdir)separate_compilation_b.cpp >> $(logfile)
g++ -m64 -c $(testdir)separate_compilation.cpp >> $(logfile)
g++ -m64 -o $(testprefix)separate_compilation$(binpostfix) *.o
-lmpfrcpp -lgmp -lgmpxx -lmpfr >> $(logfile)
then , in the main mpfrcpp-1.4.1 directory, I:
sudo make install
make check for all three packages now works fine
and I can move on to trying to use mpfrcpp for my own package.
=============================================================================
>From the web:
When GMP 4.2.1 is built and installed without any particular configure
option (except --prefix) on my Mac OS X machine (PowerPC G5), I now
get
the following error when building MPFR:
[...]
/bin/sh ./libtool --tag=CC --mode=link gcc -m64 -Wl,-
search_paths_first
-L/Users/vinc17/gmp64/lib -o libmpfr.la -rpath /usr/local/lib -version-
info
1:1:0 exceptions.lo [...] lngamma.lo -lgmp
rm -fr .libs/libmpfr.1.0.1.dylib
gcc -dynamiclib ${wl}-flat_namespace ${wl}-undefined ${wl}suppress -o
.libs/libmpfr.1.0.1.dylib .libs/exceptions.o [...] .libs/lngamma.o
-L/Users/vinc17/gmp64/lib /Users/vinc17/gmp64/lib/libgmp.a -m64
-Wl,-search_paths_first -install_name /usr/local/lib/libmpfr.1.dylib
-Wl,-compatibility_version -Wl,2 -Wl,-current_version -Wl,2.1
ld64 failed: absolute addressing (perhaps -mdynamic-no-pic) used in
___gmpn_popcount from /Users/vinc17/gmp64/lib/libgmp.a(popcount.o) not
allowed
in slidable image
checking for valid BITS_PER_MP_LIMB and BYTES_PER_MP_LIMB... no
configure: error: BITS_PER_MP_LIMB or BYTES_PER_MP_LIMB are incorrect.
You probably need to change some of the GMP or MPFR compile options.
I still went ahead with make and make check and it all seemed to work
make
sudo make install
/usr/bin/libtool: internal link edit command failed
make[1]: *** [libmpfr.la] Error 1
make: *** [all-recursive] Error 1
It was working in the past. But it seems that the latest security
update of Mac OS X made this bug appeared (I wonder why).
Using the --with-pic configure option fixes the problem.
Now, the other problem is that the shared library isn't built,
probably
because the configure script said:
checking whether the gcc linker (/usr/bin/ld) supports shared
libraries... no
It seems that autoconf 2.59 (which was used to build the configure
script provided in the GMP 4.2.1 archive) is either buggy or too old.
I have no such problem after regenerating the configure script with
autoreconf (autoconf 2.60 is installed on my machine).
===================================================================================
`--with-pic'
In normal operation, Libtool will build shared libraries from PIC
objects and static archives from non-PIC
objects, except where one or the other is not provided by the target
host. By specifying `--with-pic' you are
asking libtool to build static archives from PIC objects, and
similarly by specifying `--without-pic' you are
asking libtool to build shared libraries from non-PIC objects.
libtool will only honour this flag where it will produce a working
library, otherwise it reverts to the
default.
On Sep 27, 3:23 am, Michael <mrubi...@uwaterloo.ca> wrote:
> I managed to get gmp, mpfr, and mpfrcpp to compile and link
> successfully.
> It took a bit of effort to get it working, so I thought I'd record my
> settings here in case
> other people find them useful
>
> machine: G5 powerpc, mac os x 10.4.10, gcc 4.0.1:
>
> settings for gmp-4.2.1:
>
> ./configure --enable-cxx --with-pic
> make
> sudo make install
> sudo cp *.h /usr/local/include/.
> (not all header files that are needed by other packages get copied
> over, so I did that manually)
>
This is very odd. Which headers aren't copied over? On OSX gmp is also
build with pic per default, so chances are that it is a linker/
compiler problem. Which version of XCode are you using? I think there
is only one or two releases (at least 2.4.1 I believe) that can
successfully do a "make check" on OSX.
> mpfr-2.3.0:
>
> ./configure --with-gmp-build=/Users/michael/math/L/packages/gmp-4.2.1
> --with-pic
> make
> sudo make install
>
> note: I first tried to configure mpfr using --with-gmp=/usr/local,
> but that produced a configure error:
> "checking for valid BITS_PER_MP_LIMB and BYTES_PER_MP_LIMB... no
> configure: error: BITS_PER_MP_LIMB or BYTES_PER_MP_LIMB are incorrect.
> You probably need to change some of the GMP or MPFR compile options."
> so I used my local build instead. Obviously, you would need to modify
> the
> path for --with-gmp-build.
Well, this sounds like a 32 vs. 64 bit issue. At least Sage builds gmp
& mpfr as 32 bit on OSX for now, but the gmp configure with recent
releases defaults to 64 bits. You can always use
ABI=32 ./configure --options
to force the build of a 32 bit API.
>
> I used --with-pic after coming on that advice via google (see below).
> Without it I was getting a weird error when linkinbg mpfr:
> "not allowed in slidable image"
>
That is an mpfr bug and should be reported.
> mpfrcpp-1.4.1:
> I was getting weird linking errors, but, on my G5, adding -m64
> as a compile option worked.
This again is the 32 vs 64 bit issue. You might want to relay this
issue to the author. If he doesn't fix it I can probably come up with
a patch that tests whether mpfr has been compiled in 32/64 bit mode
and set the proper compilation flags.
Cheers,
Michael
The only thing I had to take care of was to add -m64 option as
I described earlier when compiling mpfrcpp.
I also had to, when configuring mpfr, use: --with-gmp-build=/Users/
michael/math/L/packages/gmp-4.2.2
rather than --wth-gmp=/usr/local
The latter led to complaints about libgmp.a not being found. Not sure
why.
I want to stick to -m64. The gmp page recommends against setting
ABI=32 if possible.