new, stubborn, MacOS `ld: library not found for -lssl`

147 views
Skip to first unread message

Dean Thompson

unread,
Nov 9, 2018, 4:12:51 PM11/9/18
to Crystal
I have read the old threads on this error, run `brew upgrade`, and rerun `xcode-select --install`. Yet this error persists: it happens each time I run `crystal play`.

It seemed to start when I upgraded my MacBook to Mojave.

Help!?
Dean

Deans-MacBook-Pro-3:joy-data-crystal dean$ crystal play
Listening on http://127.0.0.1:8080
ld: library not found for -lssl (this usually means you need to install the development package for libssl)
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Error: execution of command failed with code: 1: `cc "${@}" -o '/Users/dean/.cache/crystal/crystal-run-play-1-1.tmp'  -rdynamic  -lz `command -v pkg-config > /dev/null && pkg-config --libs --silence-errors libssl || printf %s '-lssl -lcrypto'` `command -v pkg-config > /dev/null && pkg-config --libs --silence-errors libcrypto || printf %s '-lcrypto'` -lpcre -lgc -lpthread /usr/local/Cellar/crystal/0.27.0/src/ext/libcrystal.a -levent -liconv -ldl -L/usr/lib -L/usr/local/lib`
Deans-MacBook-Pro-3:joy-data-crystal dean$ brew upgrade openssl
Updating Homebrew...
==> Auto-updated Homebrew!
Updated 1 tap (homebrew/cask).
No changes to formulae.

Error: openssl 1.0.2p already installed
Deans-MacBook-Pro-3:joy-data-crystal dean$ xcode-select --install
xcode-select: error: command line tools are already installed, use "Software Update" to install updates
Deans-MacBook-Pro-3:joy-data-crystal dean$

Jason Frey

unread,
Nov 10, 2018, 1:16:45 PM11/10/18
to Crystal
It may be installed by homebrew, but since it's keg-only, perhaps it can't be seen?  You can try

    brew unlink openssl && brew link openssl --force

Jason

Dean Thompson

unread,
Nov 11, 2018, 8:13:12 AM11/11/18
to Crystal
Thank you, Jason! Those commands got me some very helpful instructions, which I followed to solve the problem:

Warning: Refusing to link macOS-provided software: openssl
If you need to have openssl first in your PATH run:
  echo 'export PATH="/usr/local/opt/openssl/bin:$PATH"' >> ~/.bash_profile

For compilers to find openssl you may need to set:
  export LDFLAGS="-L/usr/local/opt/openssl/lib"
  export CPPFLAGS="-I/usr/local/opt/openssl/include"

For pkg-config to find openssl you may need to set:
  export PKG_CONFIG_PATH="/usr/local/opt/openssl/lib/pkgconfig"

Sergey Kuznetsov

unread,
Nov 18, 2018, 9:40:49 PM11/18/18
to Crystal
I had similar problem which I solved by prepending PKG_CONFIG_PATH before crystal command.
You can just add it into your ~/.bash_profile file
Reply all
Reply to author
Forward
0 new messages