grobian / carbon-c-relay

Enhanced C implementation of Carbon relay, aggregator and rewriter
Apache License 2.0
380 stars 107 forks source link

Linking failure with OpenSSL 1.1 #332

Closed shastah closed 6 years ago

shastah commented 6 years ago

Trying to compile with OpenSSL 1.1 leads to:

checking openssl/err.h usability... yes
checking openssl/err.h presence... yes
checking for openssl/err.h... yes
checking openssl/ssl.h usability... yes
checking openssl/ssl.h presence... yes
checking for openssl/ssl.h... yes
checking for SSL_connect in -lssl... yes
checking for OPENSSL_add_all_algorithms_noconf in -lcrypto... no
(...)
gcc   -o relay relay.o md5.o consistent-hash.o receptor.o dispatcher.o conffile.tab.o conffile.yy.o allocator.o router.o queue.o server.o collector.o aggregator.o -lz -llz4 -lssl  -lpcre2-posix  -lm  -pthread
/usr/bin/ld: server.o: undefined reference to symbol 'ERR_reason_error_string@@OPENSSL_1_1_0'
/lib64/libcrypto.so.1.1: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
make[1]: *** [Makefile:507: relay] Error 1

Adding -lcrypto to LIBSSL in Makefile resolves the issue (but configure should handle that for me).

grobian commented 6 years ago

agreed, thanks for the issue

grobian commented 6 years ago

Can you perhaps send me the relevant snippet from config.log around the OPENSSL_add_all_algorithms_noconf check? I'd like to see what the actual problem/error is.

hnakamur commented 6 years ago

Hi, I have the same problem. Here is the relevant snippet from config.log.

configure:5246: checking for OPENSSL_add_all_algorithms_noconf in -lcrypto
configure:5271: gcc -o conftest -g -O2 -fdebug-prefix-map=/build/carbon-c-relay-Ik8vNO/carbon-c-relay-3.3=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -Wl,-Bsymbolic-functions -Wl,-z,relro conftest.c -lcrypto  -lm  -pthread >&5
/tmp/ccz7ASkm.o: In function `main':
./conftest.c:85: undefined reference to `OPENSSL_add_all_algorithms_noconf'
collect2: error: ld returned 1 exit status
configure:5271: $? = 1
configure: failed program was:
| /* confdefs.h */
| #define PACKAGE_NAME "carbon-c-relay"
| #define PACKAGE_TARNAME "carbon-c-relay"
| #define PACKAGE_VERSION "3.3"
| #define PACKAGE_STRING "carbon-c-relay 3.3"
| #define PACKAGE_BUGREPORT ""
| #define PACKAGE_URL ""
| #define PACKAGE "carbon-c-relay"
| #define VERSION "3.3"
| #define STDC_HEADERS 1
| #define HAVE_SYS_TYPES_H 1
| #define HAVE_SYS_STAT_H 1
| #define HAVE_STDLIB_H 1
| #define HAVE_STRING_H 1
| #define HAVE_MEMORY_H 1
| #define HAVE_STRINGS_H 1
| #define HAVE_INTTYPES_H 1
| #define HAVE_STDINT_H 1
| #define HAVE_UNISTD_H 1
| #define HAVE_ARPA_INET_H 1
| #define HAVE_ASSERT_H 1
| #define HAVE_ERRNO_H 1
| #define HAVE_FCNTL_H 1
| #define HAVE_GLOB_H 1
| #define HAVE_MATH_H 1
| #define HAVE_NETDB_H 1
| #define HAVE_NETINET_IN_H 1
| #define HAVE_NETINET_TCP_H 1
| #define HAVE_POLL_H 1
| #define HAVE_PTHREAD_H 1
| #define HAVE_REGEX_H 1
| #define HAVE_SIGNAL_H 1
| #define HAVE_STDARG_H 1
| #define HAVE_STDIO_H 1
| #define HAVE_STDLIB_H 1
| #define HAVE_STRING_H 1
| #define HAVE_SYS_RESOURCE_H 1
| #define HAVE_SYS_SOCKET_H 1
| #define HAVE_SYS_STAT_H 1
| #define HAVE_SYS_TIME_H 1
| #define HAVE_SYS_TYPES_H 1
| #define HAVE_SYS_UIO_H 1
| #define HAVE_SYS_UN_H 1
| #define HAVE_TIME_H 1
| #define HAVE_UNISTD_H 1
| #define HAVE_FORK 1
| #define HAVE_VFORK 1
| #define HAVE_WORKING_VFORK 1
| #define HAVE_WORKING_FORK 1
| #define HAVE_STDLIB_H 1
| #define HAVE_MALLOC 1
| #define HAVE_STDLIB_H 1
| #define HAVE_REALLOC 1
| #define HAVE_GETHOSTNAME 1
| #define HAVE_GETTIMEOFDAY 1
| #define HAVE_LOCALTIME_R 1
| #define HAVE_MEMMOVE 1
| #define HAVE_MEMSET 1
| #define HAVE_POW 1
| #define HAVE_REGCOMP 1
| #define HAVE_SOCKET 1
| #define HAVE_SQRT 1
| #define HAVE_STRCHR 1
| #define HAVE_STRDUP 1
| #define HAVE_STRERROR 1
| #define HAVE_STRSTR 1
| #define HAVE_STRTOL 1
| #define HAVE_LZ4_H 1
| #define HAVE_LZ4 1
| #define HAVE_OPENSSL_ERR_H 1
| #define HAVE_OPENSSL_SSL_H 1
| #define HAVE_SSL 1
| /* end confdefs.h.  */
| 
| /* Override any GCC internal prototype to avoid an error.
|    Use char because int might match the return type of a GCC
|    builtin and then its argument prototype would still apply.  */
| #ifdef __cplusplus
| extern "C"
| #endif
| char OPENSSL_add_all_algorithms_noconf ();
| int
| main ()
| {
| return OPENSSL_add_all_algorithms_noconf ();
|   ;
|   return 0;
| }
configure:5280: result: no

I tweaked conftest.c as below:

/* confdefs.h */
#define PACKAGE_NAME "carbon-c-relay"
#define PACKAGE_TARNAME "carbon-c-relay"
#define PACKAGE_VERSION "3.3"
#define PACKAGE_STRING "carbon-c-relay 3.3"
#define PACKAGE_BUGREPORT ""
#define PACKAGE_URL ""
#define PACKAGE "carbon-c-relay"
#define VERSION "3.3"
#define STDC_HEADERS 1
#define HAVE_SYS_TYPES_H 1
#define HAVE_SYS_STAT_H 1
#define HAVE_STDLIB_H 1
#define HAVE_STRING_H 1
#define HAVE_MEMORY_H 1
#define HAVE_STRINGS_H 1
#define HAVE_INTTYPES_H 1
#define HAVE_STDINT_H 1
#define HAVE_UNISTD_H 1
#define HAVE_ARPA_INET_H 1
#define HAVE_ASSERT_H 1
#define HAVE_ERRNO_H 1
#define HAVE_FCNTL_H 1
#define HAVE_GLOB_H 1
#define HAVE_MATH_H 1
#define HAVE_NETDB_H 1
#define HAVE_NETINET_IN_H 1
#define HAVE_NETINET_TCP_H 1
#define HAVE_POLL_H 1
#define HAVE_PTHREAD_H 1
#define HAVE_REGEX_H 1
#define HAVE_SIGNAL_H 1
#define HAVE_STDARG_H 1
#define HAVE_STDIO_H 1
#define HAVE_STDLIB_H 1
#define HAVE_STRING_H 1
#define HAVE_SYS_RESOURCE_H 1
#define HAVE_SYS_SOCKET_H 1
#define HAVE_SYS_STAT_H 1
#define HAVE_SYS_TIME_H 1
#define HAVE_SYS_TYPES_H 1
#define HAVE_SYS_UIO_H 1
#define HAVE_SYS_UN_H 1
#define HAVE_TIME_H 1
#define HAVE_UNISTD_H 1
#define HAVE_FORK 1
#define HAVE_VFORK 1
#define HAVE_WORKING_VFORK 1
#define HAVE_WORKING_FORK 1
#define HAVE_STDLIB_H 1
#define HAVE_MALLOC 1
#define HAVE_STDLIB_H 1
#define HAVE_REALLOC 1
#define HAVE_GETHOSTNAME 1
#define HAVE_GETTIMEOFDAY 1
#define HAVE_LOCALTIME_R 1
#define HAVE_MEMMOVE 1
#define HAVE_MEMSET 1
#define HAVE_POW 1
#define HAVE_REGCOMP 1
#define HAVE_SOCKET 1
#define HAVE_SQRT 1
#define HAVE_STRCHR 1
#define HAVE_STRDUP 1
#define HAVE_STRERROR 1
#define HAVE_STRSTR 1
#define HAVE_STRTOL 1
#define HAVE_LZ4_H 1
#define HAVE_LZ4 1
#define HAVE_OPENSSL_ERR_H 1
#define HAVE_OPENSSL_SSL_H 1
#define HAVE_SSL 1
/* end confdefs.h.  */
#include <openssl/crypto.h>
#include <openssl/evp.h>

int
main ()
{
return OPENSSL_add_all_algorithms_noconf ();
  ;
  return 0;
}

With the above modification, it compiles successfully.

# gcc -o conftest -g -O2 -fdebug-prefix-map=/build/carbon-c-relay-Ik8vNO/carbon-c-relay-3.3=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -Wl,-Bsymbolic-functions -Wl,-z,relro conftest.c -lcrypto
# echo $?
0
hnakamur commented 6 years ago

By the way, I created a PPA deb package of carbon-c-relay for Ubuntu 18.04 LTS. https://launchpad.net/~hnakamur/+archive/ubuntu/carbon-c-relay

grobian commented 6 years ago

ok, thanks, so we should check another symbol :)