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

Unable to build erlang 19.x #195

Closed
returntrip opened this issue May 14, 2017 · 8 comments
Closed

Unable to build erlang 19.x #195

returntrip opened this issue May 14, 2017 · 8 comments

Comments

@returntrip
Copy link

Hi Folks,

Wonder if you can help me understand why I get this error and how can I overcome it? Thanks.

crypto.c:131:28: fatal error: openssl/chacha.h: No such file or directory
 #include <openssl/chacha.h>
                            ^
compilation terminated.
make[4]: *** [x86_64-unknown-linux-gnu/Makefile:136: ../priv/obj/x86_64-unknown-linux-gnu/crypto.o] Error 1
make[4]: Leaving directory '/tmp/erlang_build_MwcZWB/otp_src_19.0/lib/crypto/c_src'
make[3]: *** [/tmp/erlang_build_MwcZWB/otp_src_19.0/make/run_make.mk:35: opt] Error 2
make[3]: Leaving directory '/tmp/erlang_build_MwcZWB/otp_src_19.0/lib/crypto/c_src'
make[2]: *** [/tmp/erlang_build_MwcZWB/otp_src_19.0/make/otp_subdir.mk:29: opt] Error 2
make[2]: Leaving directory '/tmp/erlang_build_MwcZWB/otp_src_19.0/lib/crypto'
make[1]: *** [/tmp/erlang_build_MwcZWB/otp_src_19.0/make/otp_subdir.mk:29: opt] Error 2
make[1]: Leaving directory '/tmp/erlang_build_MwcZWB/otp_src_19.0/lib'
make: *** [Makefile:452: libs] Error 2
@danhper
Copy link
Member

danhper commented May 15, 2017

I am having the same issue on ArchLinux, I think it is because ArchLinux uses openssl 1.1, but I am not sure how to work around it. I tried to pass --with-ssl and --with-ssl-incl flags to configure to use openssl 1.0, but it did not work for me.
I will update if I find anything interesting.

@danhper
Copy link
Member

danhper commented May 15, 2017

tldr (if on ArchLinux)

asdf plugin-update erlang
wget -O /tmp/link-openssl.sh https://gist.githubusercontent.com/tuvistavie/22554261f3e613703d76d882977290f1/raw/0f244ae93e980160492bd9fc9bc84797f16ac10a/archlinux-link-openssl1-0.sh
sudo bash /tmp/link-openssl.sh /usr/local/openssl-1.0
ERLANG_OPENSSL_PATH="/usr/local/openssl-1.0" asdf install erlang 19.3

Explanations

After trying a few things, here are the results:

  • The issue is definitely that Erlang/OTP does not build with OpenSSL 1.1
  • ArchLinux openssl 1.0 package directory structure does not play well with erlang --with-ssl flag. The directory structure should be something like DIR/lib/libssl.so for it to work with --with-ssl=DIR, but it is installed at /usr/lib/openssl-1.0/libssl.so

Let's assume that we want to have OpenSSL 1.0 in $HOME/.openssl-1.0 (if we want to make this /usr/local/openssl-1.0, or something not inside user home, some steps will require sudo)

  1. First, we need to have OpenSSL 1.0 installed with a a directory structure that Erlang build scripts will understand.
    We have two choices:

    1. Compile OpenSSL 1.0 from sources. This can be done with the following steps:
    git clone https://github.com/openssl/openssl.git --branch OpenSSL_1_0_2-stable
    ./config --prefix=$HOME/.openssl-1.0 shared -fPIC
    make depend && make && make install
    
    1. Link the lib and include provided in Arch openssl-1.0 package. This can be done with the following steps:
    mkdir -p $HOME/.openssl-1.0
    cd $HOME/.openssl.1-0
    ln -sf /usr/lib/openssl-1.0 lib
    ln -sf /usr/include/openssl-1.0 include
    

    I created a gist with the steps here: https://gist.github.com/tuvistavie/22554261f3e613703d76d882977290f1

    I would rather go with the second solution, as it avoids having to maintain an OpenSSL install for no good reason.

  2. Then we need to path --with-ssl to ./configure in Erlang so that it uses OpenSSL 1.0 and not 1.1.
    I updated asdf-erlang to support the ERLANG_OPENSSL_PATH environment variable to make this easier, as the --with-ssl option was currently overriden.
    Erlang can therefore be installed using:

    ERLANG_OPENSSL_PATH="$HOME/.openssl-1.0" asdf install erlang 19.3
    

Let me know how this works for you.

NOTE: do not forget to run asdf plugin-update erlang before installing anything.

@returntrip
Copy link
Author

@tuvistavie thanks for the help! That worked fine!

@holzingk
Copy link

Fedora 27 users can install compat-openssl10-devel.

@Stratus3D
Copy link
Member

Thanks for the detailed comment @tuvistavie ! I added it to the asdf-erlang wiki: https://github.com/asdf-vm/asdf-erlang/wiki/OpenSSL-on-ArchLinux

@danhper
Copy link
Member

danhper commented Nov 17, 2017

Great, thank you!

@dkuku
Copy link

dkuku commented Dec 13, 2018

I had a problem with version from this manual but works with the latest one without any chanages
asdf install erlang 21.1.3 - now I can do mix deps.get

@lytedev
Copy link

lytedev commented Sep 21, 2023

For other lost souls (and for myself in the future when I find myself back here again), this worked for me:

$ sudo pacman -S openssl-1.1
$ sudo mkdir -p /opt/openssl-1.1
$ sudo ln -s /usr/lib/openssl-1.1/ /opt/openssl1.1/lib
$ sudo ln -s /usr/include/openssl-1.1/ /opt/openssl1.1/include
$ ERLANG_OPENSSL_PATH="/opt/openssl-1.1" KERL_CONFIGURE_OPTIONS="--with-ssl=/opt/openssl-1.1" \
  asdf install erlang $ERLANG_VERSION
$ asdf install elixir $ELIXIR_VERSION

One or more chunks of this may be redundant, but this worked.

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

No branches or pull requests

6 participants