(note beforehand that if you know an easy-to-use bigint type library that you can give me step by step instruction on how to set up, you have done far more for me than solving this problem would. That'd be great. )
Here's what's happening:
I am trying to compile this C++ program:
However, when I compile it like this:Code:#include <iostream> #include <gmpxx.h> int Ackermann(int m, int n); using namespace std; int main(void) { mpz_class a; a = 1; a = a*a; a = a*a; cout<< a; /* int m = 4, n = 4; cout <<"\n\nAckermann's function for (" << m << "," << n << ") is " << Ackermann(m,n); return 0;*/ } int Ackermann(int m, int n) { if (m == 0) { return (n+1); } else if (n == 0) { return (Ackermann(m-1,1)); } else { return (Ackermann(m-1,Ackermann(m,n-1))); } }
And then run it, I get this error:g++ ackermann.cpp -o ackermann -lgmpxx -lgmp
Now, it is fairly obvious that it can't find the shared libraries. I figured I'd see what I could do to fix it, and came across this rather interesting file: /home/james/gmp-4.2.4/libgmpxx.la./ackermann: error while loading shared libraries: libgmpxx.so.4: cannot open shared object file: No such file or directory
Here are the contents:
It looks to me like if g++ could make use of the information in this file, it might be happy. I'm not entirely sure, however.# libgmpxx.la - a libtool library file
# Generated by ltmain.sh - GNU libtool 1.5.24 (1.1220.2.455 2007/06/24 02:13:29)
#
# Please DO NOT delete this file!
# It is necessary for linking the library.
# The name that we can dlopen(3).
dlname='libgmpxx.so.4'
# Names of this library.
library_names='libgmpxx.so.4.0.4 libgmpxx.so.4 libgmpxx.so'
# The name of the static archive.
old_library='libgmpxx.a'
# Libraries that this one depends upon.
dependency_libs=' /home/james/gmp-4.2.4/libgmp.la'
# Version information for libgmpxx.
current=4
age=0
revision=4
# Is this an already installed library?
installed=no
# Should we warn about portability when linking against -modules?
shouldnotlink=no
# Files to dlopen/dlpreopen
dlopen=''
dlpreopen=''
# Directory that this library needs to be installed in:
libdir='/usr/local/lib'
relink_command="(cd /home/james/gmp-4.2.4; /bin/bash ./libtool --mode=relink g++ -m32 -O2 -fomit-frame-pointer -mtune=core2 -march=core2 -o libgmpxx.la -rpath /usr/local/lib -version-info 4:4:0 dummy.lo cxx/isfuns.lo cxx/ismpf.lo cxx/ismpq.lo cxx/ismpz.lo cxx/ismpznw.lo cxx/osdoprnti.lo cxx/osfuns.lo cxx/osmpf.lo cxx/osmpq.lo cxx/osmpz.lo libgmp.la @inst_prefix_dir@) "
Now, I've done a fair bit of Linux and command-line related work, as well as C++ programming, but I haven't done much of the two together. Maybe it's as simple as setting an environment variable. Any help would be much appreciate, however, and I would think of you when I finish this assignment.
Bookmarks