apache安装报错undefined reference ssl

作者:csuper 发表于:2016-12-28

 

apache安装报错undefined reference ssl

编译安装apache httpd,configure没有报错,但make的时候报如下错误:


/software/httpd-2.4.9/support/ab.c:735: undefined reference to `SSL_write'
ab.o: In function `ssl_proceed_handshake':
/software/httpd-2.4.9/support/ab.c:650: undefined reference to `SSL_do_handshake'
/software/httpd-2.4.9/support/ab.c:651: undefined reference to `SSL_get_error'
ab.o: In function `ssl_print_info':
/software/httpd-2.4.9/support/ab.c:623: undefined reference to `SSL_get_peer_cert_chain'
/software/httpd-2.4.9/support/ab.c:631: undefined reference to `SSL_get_peer_certificate'
ab.o: In function `ssl_print_connection_info':
/software/httpd-2.4.9/support/ab.c:572: undefined reference to `SSL_get_version'
/software/httpd-2.4.9/support/ab.c:574: undefined reference to `SSL_get_current_cipher'
/software/httpd-2.4.9/support/ab.c:575: undefined reference to `SSL_CIPHER_get_version'
/software/httpd-2.4.9/support/ab.c:576: undefined reference to `SSL_CIPHER_get_name'
/software/httpd-2.4.9/support/ab.c:578: undefined reference to `SSL_CIPHER_get_bits'
ab.o: In function `ssl_print_info':
/software/httpd-2.4.9/support/ab.c:640: undefined reference to `SSL_get_session'
/software/httpd-2.4.9/support/ab.c:640: undefined reference to `SSL_SESSION_print'
ab.o: In function `ssl_proceed_handshake':
/software/httpd-2.4.9/support/ab.c:662: undefined reference to `SSL_get_current_cipher'
/software/httpd-2.4.9/support/ab.c:663: undefined reference to `SSL_CIPHER_get_bits'
/software/httpd-2.4.9/support/ab.c:664: undefined reference to `SSL_get_peer_certificate'
/software/httpd-2.4.9/support/ab.c:671: undefined reference to `SSL_CIPHER_get_name'
/software/httpd-2.4.9/support/ab.c:671: undefined reference to `SSL_get_version'
ab.o: In function `start_connect':
/software/httpd-2.4.9/support/ab.c:1278: undefined reference to `SSL_new'
/software/httpd-2.4.9/support/ab.c:1286: undefined reference to `SSL_set_bio'
/software/httpd-2.4.9/support/ab.c:1287: undefined reference to `SSL_set_connect_state'
ab.o: In function `close_connection':
/software/httpd-2.4.9/support/ab.c:1369: undefined reference to `SSL_shutdown'
/software/httpd-2.4.9/support/ab.c:1370: undefined reference to `SSL_free'
ab.o: In function `read_connection':
/software/httpd-2.4.9/support/ab.c:1395: undefined reference to `SSL_read'
/software/httpd-2.4.9/support/ab.c:1397: undefined reference to `SSL_get_error'
ab.o: In function `test':
/software/httpd-2.4.9/support/ab.c:1810: undefined reference to `SSL_state'
ab.o: In function `ssl_state_cb':
/software/httpd-2.4.9/support/ab.c:511: undefined reference to `SSL_state_string_long'
/software/httpd-2.4.9/support/ab.c:511: undefined reference to `SSL_state'
/software/httpd-2.4.9/support/ab.c:506: undefined reference to `SSL_alert_desc_string_long'
/software/httpd-2.4.9/support/ab.c:506: undefined reference to `SSL_alert_type_string_long'
/software/httpd-2.4.9/support/ab.c:515: undefined reference to `SSL_state_string_long'
ab.o: In function `main':
/software/httpd-2.4.9/support/ab.c:2092: undefined reference to `SSLv23_client_method'
/software/httpd-2.4.9/support/ab.c:2367: undefined reference to `SSL_load_error_strings'
/software/httpd-2.4.9/support/ab.c:2368: undefined reference to `SSL_library_init'
/software/httpd-2.4.9/support/ab.c:2372: undefined reference to `SSL_CTX_new'
/software/httpd-2.4.9/support/ab.c:2377: undefined reference to `SSL_CTX_ctrl'
/software/httpd-2.4.9/support/ab.c:2380: undefined reference to `SSL_CTX_ctrl'
/software/httpd-2.4.9/support/ab.c:2383: undefined reference to `SSL_CTX_set_cipher_list'
/software/httpd-2.4.9/support/ab.c:2308: undefined reference to `SSLv2_client_method'
/software/httpd-2.4.9/support/ab.c:2305: undefined reference to `SSLv23_client_method'
/software/httpd-2.4.9/support/ab.c:2390: undefined reference to `SSL_CTX_set_info_callback'
/software/httpd-2.4.9/support/ab.c:2314: undefined reference to `TLSv1_1_client_method'
/software/httpd-2.4.9/support/ab.c:2311: undefined reference to `SSLv3_client_method'
/software/httpd-2.4.9/support/ab.c:2316: undefined reference to `TLSv1_2_client_method'
/software/httpd-2.4.9/support/ab.c:2319: undefined reference to `TLSv1_client_method'
collect2: ld returned 1 exit status
make[2]: *** [ab] 错误 1
make[2]: Leaving directory `/software/httpd-2.4.9/support'
make[1]: *** [all-recursive] 错误 1
make[1]: Leaving directory `/software/httpd-2.4.9/support'
make: *** [all-recursive] 错误 1


检查发现是configure的时候没有添加--with-ssl=/usr/local/openssl-1.0.1g(重新编译安装后openssl的路径)的路径,添加后可解决以上报错的问题。

./configure --prefix=/home/apache-249  --enable-ssl --with-ssl=/usr/local/openssl-1.0.1g --with-pcre=/usr/local/pcre --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util --enable-so  --enable-rewrite --enable-modules=most --enable-mods-shared=most --enable-mpms-shared=all --with-mpm=event


如果不使用ssl,也可以在编译时候去掉--enable-ssl --with-ssl=/usr/local/openssl-1.0.1g,加上--disable-ssl 。



试过使用1.1.0b版本(openssl-1.1.0b.tar.gz),但是在编译Apache HTTP Server 2.4.23的时候遇到以下错误,觉得是版本不兼容,所以使用openssl-1.0.2i版本:


ab.c:2416: warning: implicit declaration of function 'CRYPTO_malloc_init'
/usr/local/apr/build-1/libtool --silent --mode=link gcc -std=gnu99 -g -O2 -pthread......
ab.o: In function `main':
httpd-2.4.23/support/ab.c:2416: undefined reference to `CRYPTO_malloc_init'
httpd-2.4.23/support/ab.c:2357: undefined reference to `SSLv2_client_method'



openssl编译:
 如果按照测试环境编译,提示如下错误(google出来的结果基本就是说bug之类的,在此顺道鄙视百度一下,连个类似的检索都没有。)
 /usr/bin/ld: /usr/local/ssl/lib/libssl.a(s3_srvr.o): relocation R_X86_64_32 against `a local symbol' can not be used when making a shared object; recompile with -fPIC

/usr/local/ssl/lib/libssl.a: could not read symbols: Bad value

collect2: ld returned 1 exit status

make[4]: *** [mod_ssl.la] Error 1

make[4]: Leaving directory `/opt/xyz/httpd-2.4.2/modules/ssl'

make[3]: *** [shared-build-recursive] Error 1

make[3]: Leaving directory `/opt/xyz/httpd-2.4.2/modules/ssl'

make[2]: *** [shared-build-recursive] Error 1

make[2]: Leaving directory `/opt/xyz/httpd-2.4.2/modules'

make[1]: *** [shared-build-recursive] Error 1

make[1]: Leaving directory `/opt/xyz/httpd-2.4.2'

make: *** [all-recursive] Error 1
这段错误说明ssl方面的错误,需要重新编译,并添加 -fPIC

64位下成功解决方法:
openssl编译:
./config --prefix=${destination_dir} -fPIC no-gost no-shared no-zlib 
 make depend ; make install
 apache 编译方法照旧

版权声明

本文仅代表作者观点,不代表Csuper立场。
本文系作者授权百度百家发表,未经许可,不得转载。