I was trying to get Crystal off the ground on MacOS Mojave and ran into a similar issue.
This is the error message I was seeing:
Error: execution of command failed with code: 1: `cc "${@}" -o '/Users/mymbp/.cache/crystal/crystal-run-server.tmp' -rdynamic
`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'` -lz -lpcre -lgc -lpthread
/usr/local/Cellar/crystal/0.27.0/src/ext/libcrystal.a -levent -liconv -ldl -
L/usr/lib -L/usr/local/lib`
Searching /usr/local/lib I noticed there was no mention of libssl.
So I added a symlink and that seemed to fix it.
ln -s /usr/local/Cellar/openssl/1.0.2p/lib/libssl.dylib /usr/local/lib/
Note: The current version of openssl that brew drops is 1.0.2p, your version may be different.
brew install libffi
stackoverflow.com/a/44707470/32453