My question is as simple as the title. I have a Macbook Pro with OS X Mavericks (10.9.4) and Xcode (5.1.1). I need to install the GMP arbitrary precision libraries so that I can just get to write GMP-enabled programs from within Xcode.
./configure --prefix=/usr/local --enable-cxx
make
make check
sudo make install
But when I go to Xcode and just #include <gmpxx.h>
it doesn't find it. Also adding -lgmp to my linker flags causes an error.
I also tried using homebrew with brew install gmp
but that didn't work either (same symptohms)
What is the correct way to solve this problem?
You need to ensure that you have an include path -I/usr/local/include
, before you can include <gmpxx.h>
(or <gmp.h>
for that matter).
Also, adding -lgmp
is insufficient, since that's only the C interface. You want to link with -lgmpxx
(the C++ library), and possible specify the path to that library with -L/usr/local/lib
.
You can run otool -L /usr/local/lib/libgmpxx.dylib
, to ensure that libgmp.dylib
is already linked to it. Which it should be.
Set the Header Search Path and Library Search Path in the Xcode Project Settings to /usr/local/include
and /usr/local/lib
respectively as, by default, these paths are not searched by Xcode.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With