crystal doesn't work with OpenSSL 1.1.0f (Debian 9)

Created on 6 Jul 2017  ·  15Comments  ·  Source: crystal-lang/crystal

Just booted up a new 64-bit 4gb Debian 9 Linux to show off my Crystal app.

Still no-go... Nothing will compile because Crystal's OpenSSL support doesn't work with the version on Debian 9.

livepost@livepost:~/amber_cmd$ make
Building amber in /home/livepost/amber_cmd
_main.o: In function `__crystal_main':
/opt/crystal/src/openssl/lib_ssl.cr:213: undefined reference to `SSL_library_init'
/opt/crystal/src/openssl/lib_ssl.cr:213: undefined reference to `SSL_load_error_strings'
/opt/crystal/src/openssl/lib_ssl.cr:213: undefined reference to `OPENSSL_add_all_algorithms_noconf'
/opt/crystal/src/openssl/lib_ssl.cr:213: undefined reference to `ERR_load_crypto_strings'
O-penS-S-L-5858S-S-L-5858C-ontext.o: In function `default_method':
/opt/crystal/src/openssl/ssl/context.cr:4: undefined reference to `SSLv23_method'
collect2: error: ld returned 1 exit status
Error: execution of command failed with code: 1: `cc "${@}" -o '/home/livepost/amber_cmd/bin/amber'  -rdynamic  -lsqlite3 `command -v pkg-config > /dev/null && pkg-config --libs libssl || printf %s '-lssl -lcrypto'` `command -v pkg-config > /dev/null && pkg-config --libs libcrypto || printf %s '-lcrypto'` -lyaml -lreadline -lpcre -lm -lgc -lpthread /opt/crystal/src/ext/libcrystal.a -levent -lrt -ldl -L/usr/lib -L/usr/local/lib`
Makefile:6: recipe for target 'build' failed
make: *** [build] Error 1

Still not sure what to do. Thanks :beers:

Most helpful comment

I get 1, BTW apt install libssl1.0-dev fix the issue to me.

All 15 comments

There is a conflict. Crystal determines 1.0.x is present, but it eventually gets linked against 1.1.0, which obviously fails. What does pkg-config libssl --mod-version reports?

livepost@livepost:~/amber_cmd$ pkg-config libssl --modversion
1.1.0f

this is an issue on latest Kali Linux too

This issue is indeed still present in:

Linux Node1 4.9.0-3-686-pae #1 SMP Debian 4.9.30-2+deb9u5 (2017-09-19) i686 GNU/Linux

Crystal 0.23.1 [e2a1389] (2017-07-13) LLVM 3.8.1

Exact same description as the OP.

I was having the same issue on WSL (aka Bash on Ubuntu on Windows) which runs Ubuntu 16.04 xenial. I've solved my problem by removing and reinstalling libssl1.1 package. Careful, removing libssl1.1 will break lots of other packages including libssl-dev, openssl etc., take a look at apt output before proceeding and reinstall other packages too.

I have the same problem with Crystal 0.24.1 on Debian Buster.

This is weird: it works on archlinux with the same pkg-config libssl --modversion as 1.1.0g.

What's the result of pkg-config --atleast-version=1.1.0 libssl; echo $? on debian systems where this fails?

I get 1, BTW apt install libssl1.0-dev fix the issue to me.

Same issue on Archlinux

[root@localhost ~]# crystal run ./test.cr 
/usr/bin/ld: _main.o: in function `__crystal_main':
/usr/lib/crystal/openssl/lib_ssl.cr:214: undefined reference to `SSL_library_init'
/usr/bin/ld: /usr/lib/crystal/openssl/lib_ssl.cr:214: undefined reference to `SSL_load_error_strings'
/usr/bin/ld: /usr/lib/crystal/openssl/lib_ssl.cr:214: undefined reference to `OPENSSL_add_all_algorithms_noconf'
/usr/bin/ld: /usr/lib/crystal/openssl/lib_ssl.cr:214: undefined reference to `ERR_load_crypto_strings'
/usr/bin/ld: O-penS-S-L-5858D-igest.o: in function `new_evp_mt_ctx':
/usr/lib/crystal/openssl/digest/digest.cr:23: undefined reference to `EVP_MD_CTX_create'
/usr/bin/ld: O-penS-S-L-5858D-igest.o: in function `finalize':
/usr/lib/crystal/openssl/digest/digest.cr:38: undefined reference to `EVP_MD_CTX_destroy'
/usr/bin/ld: O-penS-S-L-5858D-igest.o: in function `clone':
/usr/lib/crystal/openssl/digest/digest.cr:42: undefined reference to `EVP_MD_CTX_create'
/usr/bin/ld: /usr/lib/crystal/openssl/digest/digest.cr:44: undefined reference to `EVP_MD_CTX_destroy'
collect2: error: ld returned 1 exit status
Error: execution of command failed with code: 1: `cc "${@}" -o '/root/.cache/crystal/crystal-run-test.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'` -lpcre -lgc -lpthread /usr/lib/crystal/ext/libcrystal.a -levent -lrt -ldl -L/usr/lib -L/usr/local/lib`
[root@localhost ~]# crystal --version
Crystal 0.26.1 (2018-09-17)

LLVM: 6.0.1
Default target: x86_64-pc-linux-gnu



md5-a5bb9d5c8f228eaa27b7970e23a3199d



[root@localhost ~]# openssl version
OpenSSL 1.1.1  11 Sep 2018



md5-a5bb9d5c8f228eaa27b7970e23a3199d



[root@localhost ~]# ldd /bin/crystal 
        linux-vdso.so.1 (0x00007ffcfe555000)
        libLLVM-6.0.so => /usr/lib/libLLVM-6.0.so (0x00007f4b07477000)
        libstdc++.so.6 => /usr/lib/libstdc++.so.6 (0x00007f4b072e8000)
        libpcre.so.1 => /usr/lib/libpcre.so.1 (0x00007f4b07076000)
        libm.so.6 => /usr/lib/libm.so.6 (0x00007f4b06ef1000)
        libgc.so.1 => /usr/lib/libgc.so.1 (0x00007f4b06c87000)
        libpthread.so.0 => /usr/lib/libpthread.so.0 (0x00007f4b06c66000)
        libevent-2.1.so.6 => /usr/lib/libevent-2.1.so.6 (0x00007f4b06a0e000)
        librt.so.1 => /usr/lib/librt.so.1 (0x00007f4b06a04000)
        libdl.so.2 => /usr/lib/libdl.so.2 (0x00007f4b069ff000)
        libgcc_s.so.1 => /usr/lib/libgcc_s.so.1 (0x00007f4b069e5000)
        libc.so.6 => /usr/lib/libc.so.6 (0x00007f4b06821000)
        /lib64/ld-linux-x86-64.so.2 => /usr/lib64/ld-linux-x86-64.so.2 (0x00007f4b0baea000)
        libffi.so.6 => /usr/lib/../lib/libffi.so.6 (0x00007f4b06618000)
        libedit.so.0 => /usr/lib/../lib/libedit.so.0 (0x00007f4b063df000)
        libz.so.1 => /usr/lib/../lib/libz.so.1 (0x00007f4b061c8000)
        libncursesw.so.6 => /usr/lib/../lib/libncursesw.so.6 (0x00007f4b05f5b000)
        libxml2.so.2 => /usr/lib/../lib/libxml2.so.2 (0x00007f4b05df3000)
        libatomic_ops.so.1 => /usr/lib/libatomic_ops.so.1 (0x00007f4b05dee000)
        libcrypto.so.1.1 => /usr/lib/libcrypto.so.1.1 (0x00007f4b05b1a000)
        libicuuc.so.62 => /usr/lib/../lib/libicuuc.so.62 (0x00007f4b05953000)
        liblzma.so.5 => /usr/lib/../lib/liblzma.so.5 (0x00007f4b0572d000)
        libicudata.so.62 => /usr/lib/../lib/libicudata.so.62 (0x00007f4b03d92000)

@MrSorcus i'm on latest archlinux and it works just fine for me. You clearly have the latest crystal package (2018-09-17) so i'm not sure what's happening.

What's pkg-config libssl --modversion for you?

@RX14

[root@localhost]# pkg-config libssl --modversion
1.1.1

Hmm... After installing pkgconf code can be compiled. My fault?

@MrSorcus might want to make an arch bug to make crystal to depend on pkgconf.

But then again crystal doesn't depend on a C compiler either so maybe base-devel is an implied dependency.

@RX14

[root@localhost]# pkg-config libssl --modversion
1.1.1

Hmm... After installing pkgconf code can be compiled. My fault?

Same here using:

  • Debian 10 (Buster) on WSL 2
  • Crystal version 0.33.0.

Also solved after installing pkgconf.

❯ pkg-config libssl --modversion
1.1.1d

If I uninstall pkgconf, it stops working:

❯ sudo apt remove pkg-config
[sudo] password for rafaelfesi:
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages were automatically installed and are no longer required:
  libglib2.0-0 libglib2.0-data libicu63 libxml2 shared-mime-info xdg-user-dirs
Use 'sudo apt autoremove' to remove them.
The following packages will be REMOVED:
  pkg-config
0 upgraded, 0 newly installed, 1 to remove and 0 not upgraded.
After this operation, 208 kB disk space will be freed.
Do you want to continue? [Y/n]
(Reading database ... 25353 files and directories currently installed.)
Removing pkg-config (0.29-6) ...
Processing triggers for man-db (2.8.5-2) ...

Testing without pkgconf:

❯ crystal src/cr-test.cr
/usr/bin/ld: _main.o: in function `__crystal_main':
/home/rafaelfesi/.asdf/installs/crystal/0.33.0/share/crystal/src/openssl/lib_ssl.cr:241: undefined reference to `SSL_library_init'
/usr/bin/ld: /home/rafaelfesi/.asdf/installs/crystal/0.33.0/share/crystal/src/openssl/lib_ssl.cr:241: undefined reference to `SSL_load_error_strings'
/usr/bin/ld: /home/rafaelfesi/.asdf/installs/crystal/0.33.0/share/crystal/src/openssl/lib_ssl.cr:241: undefined reference to `OPENSSL_add_all_algorithms_noconf'
/usr/bin/ld: /home/rafaelfesi/.asdf/installs/crystal/0.33.0/share/crystal/src/openssl/lib_ssl.cr:241: undefined reference to `ERR_load_crypto_strings'
collect2: error: ld returned 1 exit status
Error: execution of command failed with code: 1: `cc "${@}" -o '/home/rafaelfesi/.cache/crystal/crystal-run-cr-test.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 -lm /home/rafaelfesi/.asdf/installs/crystal/0.33.0/bin/../lib/crystal/lib/libgc.a -lpthread /home/rafaelfesi/.asdf/installs/crystal/0.33.0/share/crystal/src/ext/libcrystal.a -levent -lrt -ldl -L/home/rafaelfesi/.asdf/installs/crystal/0.33.0/bin/../lib/crystal/lib -L/usr/lib -L/usr/local/lib`

As we can see, the command fails because pkg-config was not installed by default and is needed.

@rafaelfesi the crystal APT package already depends on pkg-config...

Was this page helpful?
0 / 5 - 0 ratings