Debian 8 Jessie, OpenSSL version 1.1.0, cURL version: 7.50.2

I am trying to build curl on a Linux Debian system. All stages go well up until trying to build with make command. The linking stage fails with the following error below:

  CC       ../lib/curl-nonblock.o
  CC       ../lib/curl-warnless.o
  CCLD     curl
../lib/.libs/libcurl.so: undefined reference to 'RAND_egd'
collect2: error: ld returned 1 exit status
Makefile:771: recipe for target 'curl' failed
make[2]: *** [curl] Error 1

RAND_egd function is part of the OpenSSL library so I ran ldd on the libcurl.so file to make sure the OpenSSL library is found, and it is judging by the output from ldd below.

linux-vdso.so.1 (0x00007ffceb5a1000)
libnghttp2.so.14 => /usr/lib/x86_64-linux-gnu/libnghttp2.so.14 (0x00007ff9ffc05000)
libidn.so.11 => /usr/lib/x86_64-linux-gnu/libidn.so.11 (0x00007ff9ff9d1000)
libssh2.so.1 => /usr/lib/x86_64-linux-gnu/libssh2.so.1 (0x00007ff9ff7a8000)
libssl.so.1.1 => /usr/local/lib/libssl.so.1.1 (0x00007ff9ff53a000)
libcrypto.so.1.1 => /usr/local/lib/libcrypto.so.1.1 (0x00007ff9ff0af000)
liblber-2.4.so.2 => /usr/lib/x86_64-linux-gnu/liblber-2.4.so.2 (0x00007ff9feea0000)
libldap_r-2.4.so.2 => /usr/lib/x86_64-linux-gnu/libldap_r-2.4.so.2 (0x00007ff9fec4e000)
libz.so.1 => /lib/x86_64-linux-gnu/libz.so.1 (0x00007ff9fea33000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007ff9fe688000)
libgcrypt.so.20 => /lib/x86_64-linux-gnu/libgcrypt.so.20 (0x00007ff9fe3a6000)
libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007ff9fe1a2000)
libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007ff9fdf85000)
libresolv.so.2 => /lib/x86_64-linux-gnu/libresolv.so.2 (0x00007ff9fdd6e000)
libsasl2.so.2 => /usr/lib/x86_64-linux-gnu/libsasl2.so.2 (0x00007ff9fdb52000)
libgnutls-deb0.so.28 => /usr/lib/x86_64-linux-gnu/libgnutls-deb0.so.28 (0x00007ff9fd833000)
/lib64/ld-linux-x86-64.so.2 (0x00007ffa0009e000)
libgpg-error.so.0 => /lib/x86_64-linux-gnu/libgpg-error.so.0 (0x00007ff9fd621000)
libp11-kit.so.0 => /usr/lib/x86_64-linux-gnu/libp11-kit.so.0 (0x00007ff9fd3db000)
libtasn1.so.6 => /usr/lib/x86_64-linux-gnu/libtasn1.so.6 (0x00007ff9fd1c7000)
libnettle.so.4 => /usr/lib/x86_64-linux-gnu/libnettle.so.4 (0x00007ff9fcf95000)
libhogweed.so.2 => /usr/lib/x86_64-linux-gnu/libhogweed.so.2 (0x00007ff9fcd66000)
libgmp.so.10 => /usr/lib/x86_64-linux-gnu/libgmp.so.10 (0x00007ff9fcae3000)
libffi.so.6 => /usr/lib/x86_64-linux-gnu/libffi.so.6 (0x00007ff9fc8db000)

So the library is there. I also checked the rand.h file in the include directory of OpenSSL and of course the function declaration is there, so it should be defined in the library. How can I find the cause of and resolve this error?

  • 2
    When configure is run, it checks for RAND_egd and it then generates lib/curl_config.h with a #define HAVE_RAND_EGD if it was indeed found. In a standard build of OpenSSL >= 1.1.0, that function is not present. So I don't know how you ended up with that define present in the curl build, but not in openssl. Multiple OpenSSL installs that confuse matters? – Daniel Stenberg Nov 8 '16 at 14:47
  • @DanielStenberg thank you and it is an honor to receive an answer from you. After trying to figure out the problem, I could not so I cleaned and built again, and that solved the problem. I did indeed have another earlier version of OpenSSL installed. – strwils Nov 10 '16 at 3:17

How to Resolve undefined reference to 'RAND_egd'

I believe you should now call RAND_add_egd. Also see simplifying rand_egd API on the openssl-dev mailing list.

The code you are compiling should have a guard for OpenSSL 1.1.0. Maybe something like:


    int rc = RAND_egd(<path>);


    int rc = RAND_add_egd(<path>);


Daniel is usually very good about keeping up with OpenSSL. It sound like you are getting a distribution's down-level version of something.

According to cURL Issue 763, cURL first added support for openssl-1.1.0-dev at least in April, 2016. The full change log is at cURL Changelog.

Related, you should probably move on from cURL 7.50.2. It has 12 known vulnerabilities. It looks like 7.51.0 was released on November 2, 2016.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.