Library not found for -lssl

Every time I want to run a crystal file I get this

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/remivillien/.cache/crystal/crystal-run-dwoom-account-backend-email.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 /usr/local/Cellar/crystal/0.29.0/embedded/lib/libgc.a -lpthread /usr/local/Cellar/crystal/0.29.0/src/ext/libcrystal.a -levent -liconv -ldl -L/usr/local/Cellar/crystal/0.29.0/embedded/lib -L/usr/lib -L/usr/local/lib`

So I looked online and founded that I need to paste this in the terminal

export PKG_CONFIG_PATH="/usr/local/opt/openssl/lib/pkgconfig"

This solves my issue. But actually not if I crystal run another file in another directory I get the same error. And every time, I need to export the PATH, if I restart my computer I need to start over, even when I exported the path previously in the same directory.

1 Like

Hi @RemiKalbe

You need to put this line inside your ~/.bashrc

Thanks this, you will not have to repeat the process on each terminal.

1 Like

Thanks! It works.