Crystal: Crystal not working in Mac OS X Mojave

Created on 26 Sep 2018  路  8Comments  路  Source: crystal-lang/crystal

After the upgrade I reinstalled xcode command line tools.
I've removed and reinstalled OpenSSL, MariaDB, Crystal via homebrew and added it back via crenv.

I get the following error.

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/bradleyhintze/workspace/nikola/truck/bin/truck' -rdynamic -lyaml -lzcommand -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.26.1_1/src/ext/libcrystal.a -levent -liconv -ldl -L/usr/lib -L/usr/local/lib

Most helpful comment

To add to what @jasdeepsingh is saying. Ensure you have installed pkg-config. This can be done running brew install pkg-config. OpenSSL also need to be installed brew install openssl.

Let pkg-config know about your OpenSSL installation.

export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/usr/local/opt/openssl/lib/pkgconfig

Verify PKG_CONFIG_PATH is set by running echo $PKG_CONFIG_PATH. Now, reinstall crystal brew uninstall crystal and brew install crystal.

All 8 comments

Solution:

export PKG_CONFIG_PATH=/usr/local/opt/openssl/lib/pkgconfig
Fish Shell: set -U -x PKG_CONFIG_PATH /usr/local/opt/openssl/lib/pkgconfig

To add to what @jasdeepsingh is saying. Ensure you have installed pkg-config. This can be done running brew install pkg-config. OpenSSL also need to be installed brew install openssl.

Let pkg-config know about your OpenSSL installation.

export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/usr/local/opt/openssl/lib/pkgconfig

Verify PKG_CONFIG_PATH is set by running echo $PKG_CONFIG_PATH. Now, reinstall crystal brew uninstall crystal and brew install crystal.

In my case all I had to do was add export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/usr/local/opt/openssl/lib/pkgconfig to my .bash_profile file.

Should this be in the docs or installation feedback so people don't have to find it via the Googles?

Happy to write a PR for that.

@joshuapinter thanks, It's already submitted in a PR https://github.com/crystal-lang/crystal-book/pull/312

Beauty, thanks! 馃憤

I first encountered this issue while install Crystal on my Mac and second time while installing icr (Crystal Interactive Shell)

Easiest way I was able to make it work was by doing:

ln -s /usr/local/Cellar/openssl/1.0.2q/lib/libssl.dylib /usr/local/lib/

(Make sure your openssl version is correct)

and then

ln -s /usr/local/opt/openssl/lib/libcrypto.dylib /usr/local/lib

Then continue with installation...

I'd suggest re-opening this until the packaging can be updated to "link directly to OpenSSL in brew" or what not...

Was this page helpful?
0 / 5 - 0 ratings