I am trying to set up the gnu multiple precision arithmetic library for some c++ programming I have to do.
I am using a system with mac osx 10.6.3 and do NOT have root user access.
I'm trying to use gmp 5.0.1.
Since I don't have root user access, I had to install to a different directory
Thus I used
./configure --prefix=~/gmp --enable-cxx
make
make install
I also ran make check and it did not report any errors.
I then went to run a test program
Compiled with no errors using
g++ gmptest.cxx -I/Users/****/gmp/lib/ -I/Users/****/gmp/include/ -L/Users/****/gmp/lib/ -lgmpxx -lgmp -o gmptest
and tried to run with
./gmptest
The error I get is
dyld: Library not loaded: /usr/local/lib/libgmpxx.4.dylib
Referenced from: /Users/****/./gmptest
Reason: image not found
Trace/BPT trap
The gmptest.cxx test program is the following
#include <gmp.h>
#include <gmpxx.h>
#include <iostream>
#include <stdlib.h>
#include <stdio.h>
using namespace std;
void foo (mpz_t result, const mpz_t param, unsigned long n)
{
unsigned long i;
mpz_mul_ui (result, param, n);
for (i = 1; i < n; i++)
mpz_add_ui (result, result, i*7);
}
int
main ()
{
mpz_t r, n;
mpz_init (r);
mpz_init_set_str (n, "123456", 0);
foo (r, n, 20L);
gmp_printf ("%Zd\n", r);
return 0;
}
It's just some program I found that should print out a number.. Not important what it does at this point, I just want it to run.
I understand the error is saying that it cant find the libgmpxx.4.dylib file in /usr/local/lib which makes sense because it isn't there. But I thought the -L and -I settings I put in the compiler options tell it to look there for the libraries, and that library DOES exist there.
What am I doing wrong? Did I miss something?
Edit:
I also checked otool -L gmptest and it shows libgmpxx.4.dylib and libgmp.10.dylib linked from /usr/local/lib . They do NOT exist in this directory, they exist in /Users/****/gmp/lib where I thought I had told it to look.