编译 Apache HTTPD 时出现 OpenSSL 错误 - 对“SSL_in_init”的未定义引用

编译 Apache HTTPD 时出现 OpenSSL 错误 - 对“SSL_in_init”的未定义引用

我们使用带有 OpenSSL 的 mod_ssl 将 Apache HTTPD 用作生产负载均衡器。我尝试在最新版本 (2.4.41) 上重新编译 Apache HTTPD,运行时遇到以下错误make。我将包含错误,但如果更多堆栈跟踪有用,我很乐意发布。

请注意,OpenSSL 当前版本为 1.1.1c,当我尝试构建 Apache HTTPD 版本 2.4.38 和 2.4.39 时遇到了同样的问题。

最初,根据其他地方的帖子,我以为这是 OpenSSL 和 Apache 之间的兼容性问题,但我无法在新的 VM 上重现该错误 - 一切都编译正常。所以一定是环境出了问题。

/etc/puppetlabs/tmp/httpd/httpd-2.4.41/srclib/apr/libtool --silent --mode=compile gcc -std=gnu99   -g -O2 -pthread      -DLINUX -D_REENTRANT -D_GNU_SOURCE   \
      -I. -I/etc/puppetlabs/tmp/httpd/httpd-2.4.41/os/unix -I/etc/puppetlabs/tmp/httpd/httpd-2.4.41/include -I/etc/puppetlabs/tmp/httpd/httpd-2.4.41/srclib/apr/include -I/etc/puppetlabs/tmp/httpd/httpd-2.4.41/srclib/apr-util/include -I/etc/puppetlabs/tmp/httpd/httpd-2.4.41/modules/aaa -I/etc/puppetlabs/tmp/httpd/httpd-2.4.41/modules/cache -I/etc/puppetlabs/tmp/httpd/httpd-2.4.41/modules/core -I/etc/puppetlabs/tmp/httpd/httpd-2.4.41/modules/database -I/etc/puppetlabs/tmp/httpd/httpd-2.4.41/modules/filters -I/etc/puppetlabs/tmp/httpd/httpd-2.4.41/modules/ldap -I/etc/puppetlabs/tmp/httpd/httpd-2.4.41/modules/loggers -I/etc/puppetlabs/tmp/httpd/httpd-2.4.41/modules/lua -I/etc/puppetlabs/tmp/httpd/httpd-2.4.41/modules/proxy -I/etc/puppetlabs/tmp/httpd/httpd-2.4.41/modules/http2 -I/etc/puppetlabs/tmp/httpd/httpd-2.4.41/modules/session -I/etc/puppetlabs/tmp/httpd/httpd-2.4.41/modules/ssl -I/etc/puppetlabs/tmp/httpd/httpd-2.4.41/modules/test -I/etc/puppetlabs/tmp/httpd/httpd-2.4.41/server -I/etc/puppetlabs/tmp/httpd/httpd-2.4.41/modules/md -I/etc/puppetlabs/tmp/httpd/httpd-2.4.41/modules/arch/unix -I/etc/puppetlabs/tmp/httpd/httpd-2.4.41/modules/dav/main -I/etc/puppetlabs/tmp/httpd/httpd-2.4.41/modules/generators -I/etc/puppetlabs/tmp/httpd/httpd-2.4.41/modules/mappers  -prefer-non-pic -static -c ab.c && touch ab.lo
/etc/puppetlabs/tmp/httpd/httpd-2.4.41/srclib/apr/libtool --silent --mode=link gcc -std=gnu99  -g -O2 -pthread    \
         -o ab  ab.lo       /etc/puppetlabs/tmp/httpd/httpd-2.4.41/srclib/apr-util/libaprutil-1.la -lexpat /etc/puppetlabs/tmp/httpd/httpd-2.4.41/srclib/apr/libapr-1.la -lrt -lcrypt -lpthread -ldl -lm -lssl -lcrypto -lrt -lcrypt -lpthread -ldl
ab.o: In function `ssl_state_cb':
/etc/puppetlabs/tmp/httpd/httpd-2.4.41/support/ab.c:575: undefined reference to `SSL_in_init'
ab.o: In function `ssl_print_cert_info':
/etc/puppetlabs/tmp/httpd/httpd-2.4.41/support/ab.c:653: undefined reference to `X509_get_version'
/etc/puppetlabs/tmp/httpd/httpd-2.4.41/support/ab.c:655: undefined reference to `X509_getm_notBefore'
/etc/puppetlabs/tmp/httpd/httpd-2.4.41/support/ab.c:659: undefined reference to `X509_getm_notAfter'
ab.o: In function `sk_X509_num':
/usr/local/include/openssl/x509.h:99: undefined reference to `OPENSSL_sk_num'
ab.o: In function `sk_X509_value':
/usr/local/include/openssl/x509.h:99: undefined reference to `OPENSSL_sk_value'
ab.o: In function `main':
/etc/puppetlabs/tmp/httpd/httpd-2.4.41/support/ab.c:2305: undefined reference to `TLS_client_method'
/etc/puppetlabs/tmp/httpd/httpd-2.4.41/support/ab.c:2560: undefined reference to `TLS_client_method'
/etc/puppetlabs/tmp/httpd/httpd-2.4.41/support/ab.c:2637: undefined reference to `OPENSSL_init_ssl'
/etc/puppetlabs/tmp/httpd/httpd-2.4.41/support/ab.c:2638: undefined reference to `OPENSSL_init_ssl'
/etc/puppetlabs/tmp/httpd/httpd-2.4.41/support/ab.c:2647: undefined reference to `SSL_CTX_set_options'
ab.o: In function `test':
/etc/puppetlabs/tmp/httpd/httpd-2.4.41/support/ab.c:1990: undefined reference to `SSL_in_init'
collect2: error: ld returned 1 exit status
make[2]: *** [ab] Error 1
make[2]: Leaving directory `/etc/puppetlabs/tmp/httpd/httpd-2.4.41/support'
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/etc/puppetlabs/tmp/httpd/httpd-2.4.41/support'
make: *** [all-recursive] Error 1

请注意,“puppetlabs”目录纯粹是因为我们让 Puppet 处理编译,尽管它所做的只是运行configuremakemake install往常一样。

答案1

这看起来似乎可以在 configure 和 compile 中找到 openssl 头文件,但在链接时找不到最大的 nary/编译库。
可能您指向 openssl 的头文件,configure 或 make 能够在非默认位置检测到它们,但您从未编译过二进制文件,或者没有将它们放在链接器默认经过的路径中。因此,除了 configure 和 make 命令以及用于编译属于 /usr/local/include/openssl 中的头文件的 openssl 的输出之外,您的完整 configure 和(如果适用)安装命令可以帮助您提供完整的答案。

如果您想在链接时包含安装在非默认路径中的库,您可能需要在配置中指定 Openssl Libdir(例如,使用 LDFLAGS 环境变量)。

相关内容