💾 Archived View for johnhame.link › posts › 2016-03-17-openssl-and-elixir.gmi captured on 2024-05-10 at 10:27:44. Gemini links have been rewritten to link to archived content
⬅️ Previous capture (2023-09-08)
-=-=-=-=-=-=-
If you're using the latest OpenSSL package from Homebrew[1], you might come across an error similar to this one from time to time:
==> fast_tls (compile) Compiled src/fast_tls_app.erl Compiled src/p1_sha.erl Compiled src/fast_tls_sup.erl Compiled src/fast_tls.erl Compiling c_src/fast_tls_drv.c c_src/fast_tls_drv.c:21:10: fatal error: 'openssl/err.h' file not found #include <openssl/err.h> ^ 1 error generated. ERROR: compile failed while processing /Users/john/Public/fap/api/api-2.1/deps/fast_tls: rebar_abort ==> api \* (Mix) Could not compile dependency :fast_tls, "/Users/john/.asdf/installs/elixir/1.2.3/.mix/rebar compile skip_deps=true deps_dir="/Users/john/Public/fap/api/api-2.1/_build/dev/lib"" command failed. You can recompile this dependency with "mix deps.compile fast_tls", update it with "mix deps.update fast_tls" or clean it with "mix deps.clean fast_tls"
The reason why this error is happening is because OpenSSL header files required to compile this (in this case) rebar module are in homebrew's `/usr/local/opt` directory. We can simply fix this by setting LDFLAGS and CFLAGS before compiling:
env LDFLAGS="-L$(brew --prefix openssl)/lib" CFLAGS="-I$(brew --prefix openssl)/include" mix compile
Simple!
The `brew --prefix` command will return the correct base directory where openSSL has been installed.