Boost logo

Boost :

Subject: Re: [boost] gmp-5.1.2 / boost-1.54 / multiprecision lib
From: Fred Schneider (frederick.schneider2011_at_[hidden])
Date: 2013-07-04 21:04:31


Thanks, guys. All set now.

>> I'm a bit of a newbie and I ran into some issues using gmp with boost.

>You need to add

>-lgmp
>to the end of your command line, and probably an -L option before that to
>point to the directory containing the gmp library files - please see the
GCC
>manual for information on those options.
>HTH, John.

Correct. Because, when using these data types, Boost.Multiprecision
simply wraps GMP. Therefore the underlying GMP library needs to
be linked into the project.

Boost.Multiprecision also provides its own set of independent types
such ass cpp_int, etc.

Sincerely, Chris.

On Thu, Jul 4, 2013 at 3:56 AM, Fred Schneider <
frederick.schneider2011_at_[hidden]> wrote:

> Hello,
>
> I'm a bit of a newbie and I ran into some issues using gmp with boost.
>
> After building gmp-5.1.2, I tried to build a simple file:
> boostMathExample.cpp, based on the documentation (using the multiprecision
> library + referencing gmp):
>
> //////////////////////////////////////////
> #include <boost/multiprecision/gmp.hpp>
>
> using namespace boost::multiprecision;
>
> int main(int argc, const char *argv[])
> {
> mpz_int v = 1;
>
> // Do some arithmetic:
> for (unsigned int i = 1; i <= 1000; ++i)
> v *= i;
>
> std::cout << v << std::endl;
> }
> ///////////////////////////////////////////////
>
> I received the following missing symbol errors when trying to build:
>
> g++ -I ~/Dev/C++/gmp-5.1.2 -I ~/Dev/C++/boost boostMathExample.cpp -O2 -o
> boostMathExample
>
> Undefined symbols:
> "_main", referenced from:
> start in crt1.10.6.o
> "___gmpz_init", referenced from:
> __static_initialization_and_destruction_0(int, int)in cccOFSnR.o
> __static_initialization_and_destruction_0(int, int)in cccOFSnR.o
> "___gmpz_clear", referenced from:
> ___tcf_1 in cccOFSnR.o
> __static_initialization_and_destruction_0(int, int)in cccOFSnR.o
> "___gmpz_set_si", referenced from:
> __static_initialization_and_destruction_0(int, int)in cccOFSnR.o
> ld: symbol(s) not found
> collect2: ld returned 1 exit status
>
> ========================================
> I'm running the following version of g++:
> i686-apple-darwin10-g++-4.2.1 (GCC) 4.2.1 (Apple Inc. build 5666) (dot 3)
>
> I configured gmp, version 5.1.2 with the following flags:
> ./configure --enable-cxx CXX=g++ CXXFLAGS=-O2 CC=g++ CFLAGS="-g -O2"
> and then ran "make" and "make check".
>
>
> Any insight would be appreciated.
>
> Thanks,
> Fred
>
>
>
>


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk