Boost logo

Boost :

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


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