I\'ve been trying to figure out why g++
cannot link a program with the armadillo library. The problem is simple:
macbook-pro:arma-xc jmlopez$ g++-4.
It is likely that your homebrew g++ was compiled with a custom prefix. The prefix for gcc is usually /usr, meaning that it will look for binaries in /usr/bin, headers in /usr/include and libraries in /usr/lib. If you've compiled with a custom prefix (/usr/local/Cellar/gcc/4.9.1/ in this case, it seems) the it won't look in /usr/lib.
LD_LIBRARY_PATH
is how you tell the runtime linker where to look for libraries. So if you had linked to /usr/my/bizarre/lib/path/libmylib.so, then you run it like this:
> LD_LIBRARY_PATH=/usr/my/bizarre/lib/path myprog
To tell g++ where to find libraries, you use the -L
command-line option. So your command-line should look like this:
g++-4.9 inputs-arma.cpp -L/usr/lib -larmadillo