esl / MongooseIM

MongooseIM is Erlang Solutions' robust, scalable and efficient XMPP server, aimed at large installations. Specifically designed for enterprise purposes, it is fault-tolerant and can utilise the resources of multiple clustered machines.
Other
1.66k stars 426 forks source link

Unable to set up Mongooseim on freshly installed Mac OS Mojave, issue with openssl #2221

Closed shubham1164 closed 5 years ago

shubham1164 commented 5 years ago

MongooseIM version: (put the version) 3.2 Installed from: (source or pkg) source Erlang/OTP version: (put the version) 21.2

Describe the issue.

I am unable to compile mongooseim from the source code on freshly installed Mac OS Mojave due to issue in the fast_tls or openSSL. I have followed all the steps mentioned in the docs like below:

  1. $brew install erlang elixir openssl expat libyaml libiconv libgd sqlite rebar rebar3 automake autoconf
  2. exported the below flags
    $ export LDFLAGS="-L/usr/local/opt/openssl/lib -undefined dynamic_lookup $LDFLAGS"
    $ export CXXFLAGS="-I/usr/local/opt/openssl/include $CXXFLAGS"
    $ export CFLAGS="-I/usr/local/opt/openssl/include $CFLAGS"
  3. sudo ./rebar3 compile

Issue

The compiling stopped after fast_tls.so:

$ sudo ./rebar3 compile
...
...
===> Compiling fast_tls
===> Linking /Users/ricky/Documents/Workspace/mongooseim/MongooseIM/_build/default/lib/fast_tls/priv/lib/fast_tls.so
$  

More tries:

I have even tried to compile or configure fast_tls from the source code, but it was not building. See logs:

  1. After exporting the flags:
    export LDFLAGS="-L/usr/local/opt/openssl/lib"
    export CFLAGS="-I/usr/local/opt/openssl/include/"
    export CPPFLAGS="-I/usr/local/opt/openssl/include/"
  2. $ sudo ./configure
    ....
    ....
    ...
    checking for stdlib.h... (cached) yes
    checking for GNU libc compatible malloc... yes
    checking for ANSI C header files... (cached) yes
    checking for erl... /usr/local/bin/erl
    checking for erlc... /usr/local/bin/erlc
    checking for SSL_free in -lssl... no
    checking for SHA1_Init in -lcrypto... no
    checking openssl/ssl.h usability... yes
    checking openssl/ssl.h presence... yes
    checking for openssl/ssl.h... yes
    checking openssl/err.h usability... yes
    checking openssl/err.h presence... yes
    checking for openssl/err.h... yes
    checking openssl/sha.h usability... yes
    checking openssl/sha.h presence... yes
    checking for openssl/sha.h... yes
    checking openssl/opensslv.h usability... yes
    checking openssl/opensslv.h presence... yes
    checking for openssl/opensslv.h... yes
    configure: error: OpenSSL 'ssl' library was not found
    $

May be elrang OTP 21.2 is causing the problems or I am unable to set up openSSL. Following are the few openssl related info.

$ which openssl
/opt/local/bin/openssl
$ openssl version -a
OpenSSL 1.0.2q  20 Nov 2018
built on: reproducible build, date unspecified
platform: darwin64-x86_64-cc
options:  bn(64,64) rc4(ptr,int) des(idx,cisc,16,int) idea(int) blowfish(idx) 
compiler: /usr/bin/clang -I. -I.. -I../include  -fPIC -fno-common -DOPENSSL_PIC -DZLIB -DOPENSSL_THREADS -D_REENTRANT -DDSO_DLFCN -DHAVE_DLFCN_H -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk -arch x86_64 -O3 -DL_ENDIAN -Wall -DOPENSSL_IA32_SSE2 -DOPENSSL_BN_ASM_MONT -DOPENSSL_BN_ASM_MONT5 -DOPENSSL_BN_ASM_GF2m -DSHA1_ASM -DSHA256_ASM -DSHA512_ASM -DMD5_ASM -DAES_ASM -DVPAES_ASM -DBSAES_ASM -DWHIRLPOOL_ASM -DGHASH_ASM -DECP_NISTZ256_ASM
OPENSSLDIR: "/opt/local/etc/openssl"

The issue seems simple and previously it was working but after the OS upgrade (Hight Sierra to Mojave) and switching from Mongooseim 3.0 to 3.2 started facing this issue.

Also see stackoverflow post regarding the same: https://stackoverflow.com/questions/54684165/unable-to-install-mongooseim-from-source-code-on-mac-os-10-14-2

shubham1164 commented 5 years ago

What must be the path of openssl, I can find following 3 options in my system: /opt/local/bin/openssl /usr/local/Cellar/openssl/1.0.2q /usr/local/opt/openssl

I don't know if it is ok to have openssl at these 3 places. May be I have incorrect linking to some path which should not happen. Please guide.

arcusfelis commented 5 years ago

I use openssl from brew:

export OPENSSL_ROOT_DIR=$(brew --prefix openssl)
export OPENSSL_LIB_DIR=$(brew --prefix openssl)"/lib"
export OPENSSL_INCLUDE_DIR=$(brew --prefix openssl)"/include"

export CFLAGS="-I$OPENSSL_INCLUDE_DIR"
export LDFLAGS="-L$OPENSSL_LIB_DIR"
fenek commented 5 years ago

Hi @shubham1164

Has @arcusfelis suggestion helped? Do you need any extra hints? :)

shubham1164 commented 5 years ago

No success. It seems there is some issue with openssl on Latest Mac

fenek commented 5 years ago

In my case following command works on Mojave and OpenSSL from Brew:

CFLAGS="-I/usr/local/Cellar/openssl/1.0.2p/include/" LDFLAGS="-L/usr/local/Cellar/openssl/1.0.2p/lib/" make

Please try to replace 1.0.2p with 1.0.2q in your case and run it for a fresh repo (just to make sure that there are no leftovers from failed builds).

shubham1164 commented 5 years ago

I have tried your suggestion and it is still not working. I think I must try to re-install openssl and other un-necessary stuff and then try again. All the above suggestions must work after that otherwise I will either re-open the case or ask it on stack-overflow. Thank you guyz. Love your support. 👍