I'm on a mac and I used homebrew
to install gmp
.
Kyumins-iMac:gcjlib math4tots$ g++ main.cpp -lgmp -lgmpxx
In file included from main.cpp:2:
./gcjlib.hpp:4:10: fatal error: 'gmpxx.h' file not found
#include <gmpxx.h>
^
1 error generated.
So then I explicitly told g++
to use /usr/local/include
Kyumins-iMac:gcjlib math4tots$ g++ main.cpp -lgmp -lgmpxx -I/usr/local/include
ld: library not found for -lgmp
clang: error: linker command failed with exit code 1 (use -v to see invocation)
So then I explicitly told g++
to use /usr/local/lib
Kyumins-iMac:gcjlib math4tots$ g++ main.cpp -lgmp -lgmpxx -I/usr/local/include -L/usr/local/lib
Kyumins-iMac:gcjlib math4tots$ ./a.out
sum is -4444
absolute value is 4444
So the only issue seems to be that g++
fails to acknowledge /usr/local
.
But it is tedious to type all this out all the time, especially when I'm just writing small single file programs.
Is there a way for me to get g++
to acknowledge the stuff in /usr/local
by default? Is there a standard way homebrew
users do this?
I'm on OS X 10.9.3 with Xcode 5.1.1 in case it is relevant.
g++
, the program you are calling isclang++
(through a confusing alias provided by apple) and your question has nothing to do with gcc. If you do install a true gcc, it is likely to work as you expect. – Henriques$ sudo rm -rf Applications/Xcode.app
worked for me in 10.12.6. – Mordentg++ --version
to see what you're actually running. – Gravestone