Unable to link GSL library in Mac OS X

2019-05-25 05:09发布

问题:

I am trying to use a gsl function in a simple C++ code. I have installed gsl using homebrew, but when I compile with "g++ J0_test.cpp -lgsl -lgslcblas", I get:

"J0_test.cpp:34:10: fatal error: 'gsl/gsl_sf_bessel.h' file not found
#include <gsl/gsl_sf_bessel.h>  // gsl Bessel special function header file"

GSL is installed by brew in /usr/local/Cellar, but it is symlinked to /usr/local/lib. So shouldn't gsl then be on the default search path of the compiler? Either way, even when I try -L /usr/local/lib, I have no luck.

Thanks!

Edit: everything works when I do g++ J0_test.cpp -I/usr/local/include/ -L /usr/local/lib/ -lgsl -lgslcblas

The question is then, why can't I just use -lgsl -lgslcblas if these are on the default path?

标签: c++ macos gcc g++ gsl