Sponsored Content
Full Discussion: Library linking with GMP
Top Forums Programming Library linking with GMP Post 302433101 by bluejayek on Monday 28th of June 2010 01:01:25 PM
Old 06-28-2010
Library linking with GMP

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

Code:
./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
Code:
g++ gmptest.cxx -I/Users/****/gmp/lib/ -I/Users/****/gmp/include/ -L/Users/****/gmp/lib/ -lgmpxx -lgmp -o gmptest

and tried to run with
Code:
./gmptest

The error I get is

Code:
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
Code:
#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.

Last edited by pludi; 06-29-2010 at 03:41 AM.. Reason: code tags, please...
 

10 More Discussions You Might Find Interesting

1. Programming

Linking problem while linking to shared library

Hi I'm getting ld: fatal: option -h and building a dynamic executable are incompatible ld: fatal: Flags processing errors When I run ld -shared -L/usr/dt/lib -lDtSvc -o builtin.so Workspace.o after running gcc -fPIC -I/usr/X11R6/include -I/usr/dt/include -c Workspace.c I'm... (6 Replies)
Discussion started by: laho
6 Replies

2. HP-UX

GMP multi precision math library

Hello all, I'm having trouble building the GNU Multi Precision (GMP 4.1.3) on the HP Intel Itanium 2 HP-UX 11i I'm hoping someone out there has had some experience building GMP on this platform. After running the ./configure and doing a make I get an error saying: `.rodata` is not a section ... (3 Replies)
Discussion started by: vyl
3 Replies

3. UNIX for Dummies Questions & Answers

Link error while linking a shared library in unix

Getting the following error , ld: /opt/syncsort39/lib/libsyncsort.sl: Mismatched ABI. 64-bit PA shared library found in 32-bit link. Is there any difference in the ld options in opt file while linking a 64 bit shared library ? Or is the problem because we are trying to link both 32 bit and 64... (3 Replies)
Discussion started by: arunkumar_mca
3 Replies

4. AIX

Help while linking the library in AIX

Hi, I have one library(libfoo.a) that is folder /home/xyz and my c program is in /home/xyz/cprog. Whenever I issue cc command cc -o test test.c -lfoo , i get the error /usr/bin/ld: cannot find -lfoo. echo $PATH has already listing of /home/xyz variable, even LIBPATH also has same entry... (0 Replies)
Discussion started by: rishisoft1
0 Replies

5. Shell Programming and Scripting

How to change a Makefile from building static library to shared library?

Hi: I have a library that it only offers Makefile for building static library. It built libxxx.a file. How do I in any way build a shared library? (either changin the Makefile or direct script or command to build shared library) Thanks. (1 Reply)
Discussion started by: cpthk
1 Replies

6. OS X (Apple)

Linking to a shared library

I'm trying to get Valgrind to work with an openmpi application in OS X. However I want to hardcode the path to a shared library called libmpiwrap-amd64-darwin.so into my application so that it is available at runtime. In Linux this is relatively simple, I would just add the option... (0 Replies)
Discussion started by: Valgrinder
0 Replies

7. Linux

./configure problem for libsf library due to apparently missing libdb library.

Hello, ./configure script fails to configure libsf. Please check the following last few lines of configure script error. checking for db1/db.h... no checking for db.h... yes checking for dbopen in -ldb1... no configure: error: No libdb? No libsf. But find command shows the following; ... (4 Replies)
Discussion started by: vectrum
4 Replies

8. AIX

Add shared members from library to same library in a different directory

I'm trying to install libiconv to AIX 7.1 from an rpm off of the perzl site. The rpm appears to install but I get this error message. add shr4.o shared members from /usr/lib/libiconv.a to /opt/freeware/lib/libiconv.a add shr.o shared members from /usr/lib/libiconv.a to ... (5 Replies)
Discussion started by: kneemoe
5 Replies

9. UNIX for Advanced & Expert Users

Installing recent version of gmp

I want to install a recent version of gmp on Fedora. Tried to use yum # yum list | grep gmp gmp.i686 4.3.1-6.fc13 @fedora gmp.x86_64 4.3.1-6.fc13 @fedora gmp-devel.x86_64 ... (3 Replies)
Discussion started by: kristinu
3 Replies

10. Programming

C++ linking library to a library

Hi All, My application main engine will use a shared library where we do many operation. We are trying to implement the linear algebra operation on the shared library for that I need to link my shared library to the lapack library in /usr/lib. Below is my make file. Can you please let me... (2 Replies)
Discussion started by: arunkumar_mca
2 Replies
sqrtd64(3M)															       sqrtd64(3M)

NAME
sqrtd64(), sqrtd128(), sqrtd32() - decimal square root functions SYNOPSIS
DESCRIPTION
returns the square root of x. is a version of it takes a argument and returns a result. is a version of it takes a argument and returns a result. These math functions are supported for HP-UX 11i Version 3 September 2008 Update and forward. USAGE
To use any of these functions, compile with the option. Make sure your program defines and then includes Link in the math library by specifying or on the linking command line. For more information, see the at the following site: RETURN VALUE
If x is +infinity, returns +infinity. If x is less than 0, returns NaN and raises the invalid exception. If x is NaN, returns NaN. raises the inexact exception whenever a rounded result does not equal the mathematical result. ERRORS
If x is less than 0, sets to SEE ALSO
cbrtd64(3M), powd64(3M), math(5). STANDARDS CONFORMANCE
These functions conform to ISO/IEC TR 24732, "Extension for the programming language C to support decimal floating-point arithmetic". HP Integrity Server Only sqrtd64(3M)
All times are GMT -4. The time now is 07:16 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy