ld: library not found for -lgsl

2020-02-27 10:48发布

问题:

I'm working in OSX and I'm attempting to run a make file and when I try I get the following:

ld: library not found for -lgsl
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [harm] Error 1

Earlier I found out the I needed to get the gsl library and I used mac ports and typed:

sudo port install gsl

into my command line window and it seemed to isntall okay. Is the missing lgsl not configured correctly or does it not come with gsl? I tried googling lgsl but didn't get much. I've only been at programming a few days and I don't know if I was supposed to set a path, or even really how to do that.

Thanks for any help you guys could offer.

回答1:

I just wanted to say that I had the exact problem on OSX. Rather than setting an environment variable, I used an additional compiler flag -L/opt/local/lib, which then lets one use -lgsl. I reference this answer.



回答2:

I got the same issue and here is how I fixed it:

export LIBRARY_PATH=/usr/local/Cellar/gsl/1.16/lib/

I had previously installed gsl using:

brew install gsl


回答3:

You need to add the path for where the macports installed the gsl library to your LD_LIBRARY_PATH environment variable (or most likely into the build script environment). I believe macports stores things in /opt/local/lib



标签: macos path gsl