Unable to link GSL library in Mac OS X

坚强是说给别人听的谎言 提交于 2019-12-07 20:01:22

问题


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?

来源:https://stackoverflow.com/questions/28441755/unable-to-link-gsl-library-in-mac-os-x

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!