ld: library not found for -lgsl
Asked Answered
G

3

35

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.

Goggler answered 22/5, 2013 at 1:39 Comment(0)
B
26

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.

Botswana answered 18/11, 2013 at 9:56 Comment(2)
This doesn't work for me. Anyone else still having this problem? EDIT: This post helped: #28442255Confiteor
@Confiteor have you tried `gsl-config --libs` when linking?Midshipmite
E
22

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
Erotogenic answered 2/2, 2016 at 3:37 Comment(5)
what is the difference between LIBRARY_PATH and LD_LIBRARY_PATH on mac? when to use them?Apulia
and where is it documented? How did you know about that?Preestablish
Chevdor thanks for sharing this, got my inkscape build moving along a little further. FWIW, /usr/local/Cellar is symlinked to /usr/local/opt i find using /usr/local/opt to be a little less brittle for use cases such as this. thanks againGourd
My homebrew Cellar folder was under /opt/homebrew, not under /usr/local/.Habsburg
@Apulia LD_LIBRARY_PATH is for dynamic linking whereas LIBRARY_PATH is for static linking. Your LD_LIBRARY_PATH will contain *.dylib files (dynamic link libraries) and your LIBRARY_PATH will contain *.a files (static libraries). Often, (but not always) the path where the dylibs and static libs are stored are the same.Siblee
D
6

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

Drysalt answered 22/5, 2013 at 1:41 Comment(2)
When I type echo $PATHS I get the following: /usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/opt/local/bin:/usr/texbin Which does show that /opt/local/lib is in my paths. I've never heard of LD_LIBRARY_PATH, and it is not set when I echo $LD_LIBRARY_PATHS, so I set it with export LD_LIBRARY_PATH="/opt/local/lib", but that still does not resolve the issue. I am not doing something right still?Goggler
Minor update: I do not know what LD_LIBRARY_PATH is exactly, but I corrected the path for LIBRARY_PATH to /opt/local/lib, and got things to run smoothly.Goggler

© 2022 - 2024 — McMap. All rights reserved.