How to CORRECTLY install gsl library in Linux?

夙愿已清 提交于 2019-12-03 16:44:24
Vinicius Kamakura

You need to link the library, assuming the make install was successful.

The gsl's documentation says this should work
(note the two necessary linking options for gsl to work: "-lgsl -lgslcblas"):

gcc -I/usr/local/include -L/usr/local/lib main.c -o main -lgsl -lgslcblas -lm

Alternative "cblas" instead of gsl's cblas is also possible as per: alternate cblas for gsl

Use pkg-config --libs gsl to find out what the necessary linkers are to be and then just link them. An optional thing would be to check pkg-config --cflags gsl. The second gives you the directory of the include files if they are not installed in the default /usr/include/ directory. If you've installed it there you can just ignore that.
The output of pkg-config --libs gsl would be
-lgsl -lgslcblas -lm
That means that those three have to be linked. So while compiling your program you do that by,
gcc name.c -lgsl -lgslcblas -lm

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