Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Crystal Play linker issue: -lssl error #7209

Closed
ctrl-dlahr opened this issue Dec 20, 2018 · 9 comments
Closed

Crystal Play linker issue: -lssl error #7209

ctrl-dlahr opened this issue Dec 20, 2018 · 9 comments

Comments

@ctrl-dlahr
Copy link

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

I was trying out crystal for the first time, so I followed: https://crystal-lang.org/docs/installation/on_mac_osx_using_homebrew.html

I did the following

brew update
brew install crystal
crystal play

I encountered the following error

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`

I then did the following

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

I restarted my machine and once again ran,

crystal play

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

@straight-shoota
Copy link
Member

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.

@ctrl-dlahr
Copy link
Author

ctrl-dlahr commented Dec 30, 2018

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"

@straight-shoota
Copy link
Member

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

@ctrl-dlahr
Copy link
Author

ctrl-dlahr commented Dec 30, 2018

@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

@straight-shoota
Copy link
Member

I'm glad this could be solved!

@bcardiff
Copy link
Member

bcardiff commented Jan 2, 2019

@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?

@ctrl-dlahr
Copy link
Author

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

@vinaysolanki
Copy link

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

@scriptmaster
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants