
Hi,
I searched the boost mailing list archives on MPFR and the last query was in
Feb 2010 so I think this may be worth a new thread.
I'm interested in using MPFR (C library for multiple-precision
floating-point computations with *correct rounding - *http://www.mpfr.org/)
with some of the boost math libraries (vectors, matrices). Support is
available to do this via the bindings in
boost/math/bindings/mpfr.hpphttp://www.boost.org/doc/libs/1_45_0/boost/math/bindings/mpfr.hpp.
As per the documentation (
http://www.boost.org/doc/libs/1_45_0/libs/math/doc/sf_and_dist/html/math_too...
):
"In order to use these bindings you will need to have installed MPFR plus
it's dependency the GMP library and the C++ wrapper for MPFR known as
gmpfrxx (or mpfr_class)."
However, when compiling the example listed in the documentation:
#include

On Tue, Feb 1, 2011 at 04:25, Novak Elliott
Hi,
I searched the boost mailing list archives on MPFR and the last query was in Feb 2010 so I think this may be worth a new thread.
I'm interested in using MPFR (C library for multiple-precision floating-point computations with *correct rounding - *http://www.mpfr.org/) with some of the boost math libraries (vectors, matrices). Support is available to do this via the bindings in boost/math/bindings/mpfr.hpphttp://www.boost.org/doc/libs/1_45_0/boost/math/bindings/mpfr.hpp. As per the documentation ( http://www.boost.org/doc/libs/1_45_0/libs/math/doc/sf_and_dist/html/math_too... ):
"In order to use these bindings you will need to have installed MPFR plus it's dependency the GMP library and the C++ wrapper for MPFR known as gmpfrxx (or mpfr_class)."
However, when compiling the example listed in the documentation:
#include
#include
int main() { mpfr_class::set_dprec(500); // 500 bit precision
//
// Note that the argument to tgamma is an expression template, // that's just fine here: //
mpfr_class v = boost::math::tgamma(sqrt(mpfr_class(2)));
std::cout << std::setprecision(50) << v << std::endl;
}
I get a large number of compile errors (attached).
I do have GMP, MPFR and gmpfrxx installed, although to get the gmpfrxx example to work (source: example.cpp) I had to comment out the reference to GMP_RND_MAX as this enumerated type value, present in MPFR version 2.4.2, has been removed from mpfr.h from version 3.0.0.
Does anyone have any experience is getting boost 1.45.0 running with MPFR 3.0.0? I'm wondering whether this an MPFR problem, a boost bindings problem, or both.
cheers, Novak.
It looks like you're not linking your program with mpfr library Surya

Yes, you're right. The object file is compiled ok:
g++ -I/path/to/boost_1_45_0 -lgmpfrxx -lmpfr -lgmpxx -lgmp -c
boost_mpfr_example.cpp
but linking fails in building the executable:
g++ -I/path/to/boost_1_45_0 -lgmpfrxx -lmpfr -lgmpxx -lgmp
boost_mpfr_example.o -o boost_mpfr_example
Actually, simply including
I get a large number of compile errors (attached).
Those are all linker errors not compiler errors - are you linking to the correct libraries?
HTH, John. _______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users

Yes, you're right. The object file is compiled ok:
g++ -I/path/to/boost_1_45_0 -lgmpfrxx -lmpfr -lgmpxx -lgmp -c boost_mpfr_example.cpp
but linking fails in building the executable:
g++ -I/path/to/boost_1_45_0 -lgmpfrxx -lmpfr -lgmpxx -lgmp boost_mpfr_example.o -o boost_mpfr_example
This is a GCC issue - the libraries being linked to must appear *after* the source files that need them. John.

Oops, a bit of a rookie error. Thanks John.
So to summarise for those that search the archives:
As per "Link Your Program to a Boost program" (
http://www.boost.org/doc/libs/1_45_0/more/getting_started/unix-variants.html...),
and other basic gcc/g++ documentation, the example "Using with MPR / GMP - a
High-Precision Floating-Point Library" (
http://www.boost.org/doc/libs/1_45_0/libs/math/doc/sf_and_dist/html/math_too...
):
boost_mpfr_example.cpp:
#include
participants (3)
-
John Maddock
-
Novak Elliott
-
Surya Kiran Gullapalli