Crystal: Crystal Play linker issue: -lssl error

Created on 21 Dec 2018  路  9Comments  路  Source: crystal-lang/crystal

OS: MacOS Mojave 10.14.2
Crystal 0.27.0 (2018-11-04)

LLVM: 6.0.1
Default target: x86_64-apple-macosx
OpenSSL version: LibreSSL 2.6.5



md5-b8196d549291a5a35b7b57d363569c64



brew update
brew install crystal
crystal play



md5-7f6ffd84b09521d78d1191f12138d0ea



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/dlahr/.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`



md5-49318ef17472c5d0fd8cd41cda160beb



xcode-select --install
xcode-select --switch /Library/Developer/CommandLineTools



md5-62be4072e963739f12d2d09f9eecaec7



crystal play

The error does not occur right away, it occurs once I visit the playground i.e. http://127.0.0.1:8080

duplicate

Most helpful comment

@straight-shoota Thank you! This does seem to have the fix.

All I needed to do after installing crystal is this,

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

All 9 comments

Hey @codingdracula, the error message says you need to install the libssl development package. Do you have that installed? I'm not a Mac user but AFAIK those xcode-select doesn't magically install some dependencies.

You can probably resolve this by running brew install openssl if you're using homebrew.

Hey @straight-shoota I am aware some dependencies are missing, but there is no documentation that states what I need. There is no libssl package to download for example. (At least I can't easily find one.) As far as I can gather on the internet it is part of OpenSSL, which why I showed in my original post that I had OpenSSL...likely there is another package I need, but I don't know what that package is.

This specifically happens when running the crystal playground. I can compile files and use the crystal compiler fine.

I have tried this on multiple computers and am convinced it is a common issue with MacOS Mojave users. Hopefully, it is a simple fix and then can be added to the Troubleshooting section in the documentation. That is why I posted the Xcode stuff, I read the documentation and it wasn't specifically for this issue, but I wanted to show I tried everything. I was not expecting "magic"

Have you taken a look at the solutions proposed in #6875?

@straight-shoota Thank you! This does seem to have the fix.

All I needed to do after installing crystal is this,

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

I'm glad this could be solved!

@codingdracula the issue happen right after launching the crystal playground server or after you try to compile some code input in the browser? If the later, can you share it?

@bcardiff The issue does not happen right away. It happens after you go to the URL. By that I mean as soon as you put that link in your browser and hit enter the error occurs.

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...

brew reinstall openssl and then
export PKG_CONFIG_PATH="/usr/local/opt/[email protected]/lib/pkgconfig"

I had to do these to get crystal play working

Was this page helpful?
0 / 5 - 0 ratings

Related issues

oprypin picture oprypin  路  3Comments

jhass picture jhass  路  3Comments

lbguilherme picture lbguilherme  路  3Comments

asterite picture asterite  路  3Comments

costajob picture costajob  路  3Comments