I am trying to compile this example program
#include <iostream>
#include <gmpxx.h>
int main(int argc, const char * argv[])
{
mpz_class rho = 3;
std:cout << rho;
return 0;
}
and I get this error:
Undefined symbols for architecture x86_64:
"___gmpz_clear", referenced from:
__gmp_expr<__mpz_struct [1], __mpz_struct [1]>::~__gmp_expr() in main-5858d5.o
"___gmpz_init_set_si", referenced from:
__gmp_expr<__mpz_struct [1], __mpz_struct [1]>::init_si(long) in main-5858d5.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
I compile my main manually with this command:
clang++ -L /opt/local/lib -I /opt/local/include -lgmpxx main.cpp
GMP has been installed through MacPorts:
$port list gmp
gmp @6.0.0 devel/gmp
Compiler's info:
$clang++ --version
Apple LLVM version 5.1 (clang-503.0.40) (based on LLVM 3.4svn)
Target: x86_64-apple-darwin13.3.0
Thread model: posix
some more info:
ll /opt/local/lib/libgmp*
/opt/local/lib/libgmp.10.dylib
/opt/local/lib/libgmp.a
/opt/local/lib/libgmp.dylib -> libgmp.10.dylib
/opt/local/lib/libgmpxx.4.dylib
/opt/local/lib/libgmpxx.a
/opt/local/lib/libgmpxx.dylib -> libgmpxx.4.dylib
and:
ll /opt/local/include/gmp*
/opt/local/include/gmp.h
/opt/local/include/gmpxx.h
Running clang++ -L /opt/local/lib -I /opt/local/include -lgmpxx -lgmp main.cpp
made the trick thanks @n.m.