Compiling / Linking issue with httpd 2.4 and APR + Ldap - "undefined reference ..."

时间:2016-07-11 20:14:12

标签: apache linker-errors

I am stuck on this linking issue with apache httpd 2.4 with APR + Ldap support. I keep getting "undefined reference" errors on the linking step. Here's what I've done:

Manually compiled & installed APR with no errors.

cd ~/httpd24/httpd-2.4.20/srclib/apr
./configure --prefix=/appserver/apache_httpd >configure.log 2>&1
make
make install

Manually compiled & installed APR-Util with no errors.

cd ~/httpd24/httpd-2.4.20/srclib/apr-util
./configure --prefix=/appserver/apache_httpd --with-ldap --with-apr=../apr --with-crypto >configure.log 2>&1
make
make install

Here's where the issue happens...

cd ~/httpd24/httpd-2.4.20
./configure --prefix=/appserver/apache_httpd --with-ldap --with-included-apr --enable-mods-shared=most --disable-http2 --with-crypto --enable-authnz-ldap --enable-ldap >configure.log 2>&1
make

[...]

gcc -std=gnu99 -g -O2 -pthread -DLINUX -D_REENTRANT -D_GNU_SOURCE -I. -I/home/asadmin/httpd24/httpd-2.4.20/os/unix -I/home/asadmin/httpd24/httpd-2.4.20/include -I/home/asadmin/httpd24/httpd-2.4.20/srclib/apr/include -I/home/asadmin/httpd24/httpd-2.4.20/srclib/apr-util/include -I/home/asadmin/httpd24/httpd-2.4.20/modules/aaa -I/home/asadmin/httpd24/httpd-2.4.20/modules/cache -I/home/asadmin/httpd24/httpd-2.4.20/modules/core -I/home/asadmin/httpd24/httpd-2.4.20/modules/database -I/home/asadmin/httpd24/httpd-2.4.20/modules/filters -I/home/asadmin/httpd24/httpd-2.4.20/modules/ldap -I/home/asadmin/httpd24/httpd-2.4.20/modules/loggers -I/home/asadmin/httpd24/httpd-2.4.20/modules/lua -I/home/asadmin/httpd24/httpd-2.4.20/modules/proxy -I/home/asadmin/httpd24/httpd-2.4.20/modules/session -I/home/asadmin/httpd24/httpd-2.4.20/modules/ssl -I/home/asadmin/httpd24/httpd-2.4.20/modules/test -I/home/asadmin/httpd24/httpd-2.4.20/server -I/home/asadmin/httpd24/httpd-2.4.20/modules/arch/unix -I/home/asadmin/httpd24/httpd-2.4.20/modules/dav/main -I/home/asadmin/httpd24/httpd-2.4.20/modules/generators -I/home/asadmin/httpd24/httpd-2.4.20/modules/mappers -c /home/asadmin/httpd24/httpd-2.4.20/server/buildmark.c
/home/asadmin/httpd24/httpd-2.4.20/srclib/apr/libtool --silent --mode=link gcc -std=gnu99 -g -O2 -pthread -o httpd modules.lo buildmark.o -export-dynamic server/libmain.la modules/core/libmod_so.la modules/http/libmod_http.la server/mpm/event/libevent.la os/unix/libos.la -lpcre /home/asadmin/httpd24/httpd-2.4.20/srclib/apr-util/libaprutil-1.la -lexpat /home/asadmin/httpd24/httpd-2.4.2a0/srclib/apr/libapr-1.la -lrt -lcrypt -lpthread
server/.libs/libmain.a(exports.o):(.data+0x27a8): undefined reference to `apr_ldap_ssl_init'
server/.libs/libmain.a(exports.o):(.data+0x27b0): undefined reference to `apr_ldap_ssl_deinit'
server/.libs/libmain.a(exports.o):(.data+0x27b8): undefined reference to `apr_ldap_init'
server/.libs/libmain.a(exports.o):(.data+0x27c0): undefined reference to `apr_ldap_info'
server/.libs/libmain.a(exports.o):(.data+0x27c8): undefined reference to `apr_ldap_get_option'
server/.libs/libmain.a(exports.o):(.data+0x27d0): undefined reference to `apr_ldap_set_option'
server/.libs/libmain.a(exports.o):(.data+0x27d8): undefined reference to `apr_ldap_rebind_init'
server/.libs/libmain.a(exports.o):(.data+0x27e0): undefined reference to `apr_ldap_rebind_add'
server/.libs/libmain.a(exports.o):(.data+0x27e8): undefined reference to `apr_ldap_rebind_remove'
server/.libs/libmain.a(exports.o):(.data+0x27f0): undefined reference to `apr_ldap_is_ldap_url'
server/.libs/libmain.a(exports.o):(.data+0x27f8): undefined reference to `apr_ldap_is_ldaps_url'
server/.libs/libmain.a(exports.o):(.data+0x2800): undefined reference to `apr_ldap_is_ldapi_url'
server/.libs/libmain.a(exports.o):(.data+0x2808): undefined reference to `apr_ldap_url_parse_ext'
server/.libs/libmain.a(exports.o):(.data+0x2810): undefined reference to `apr_ldap_url_parse'
collect2: ld returned 1 exit status
make[1]: *** [httpd] Error 1
make[1]: Leaving directory `/home/asadmin/httpd24/httpd-2.4.20'
make: *** [all-recursive] Error 1 

Doing some research online, I learned about the "nm" tool and the --demangle option which is often used to troubleshoot linking related issues. I admit I am not experienced enough to take full advantage of this tool and it's findings, but here's what I found out:

asadmin@packaging:~/httpd24/httpd-2.4.20> for f in `find . -type f -name "*.o"`; do obj_file="$f"; nm --demangle $f | grep apr_ldap_ && echo "^ $obj_file"; done
0000000000000000 t apr_ldap_pool_cleanup_set_null
00000000000000b0 t apr_ldap_rebind_remove_helper
0000000000000000 b apr_ldap_xref_lock
^ ./srclib/apr-util-1.5.4/ldap/.libs/apr_ldap_rebind.o
0000000000000000 t apr_ldap_pool_cleanup_set_null
00000000000000b0 t apr_ldap_rebind_remove_helper
0000000000000000 b apr_ldap_xref_lock
^ ./srclib/apr-util-1.5.4/ldap/apr_ldap_rebind.o
00000000000027c8 D ap_hack_apr_ldap_get_option
00000000000027c0 D ap_hack_apr_ldap_info
00000000000027b8 D ap_hack_apr_ldap_init
00000000000027f0 D ap_hack_apr_ldap_is_ldap_url
0000000000002800 D ap_hack_apr_ldap_is_ldapi_url
00000000000027f8 D ap_hack_apr_ldap_is_ldaps_url
00000000000027e0 D ap_hack_apr_ldap_rebind_add
00000000000027d8 D ap_hack_apr_ldap_rebind_init
00000000000027e8 D ap_hack_apr_ldap_rebind_remove
00000000000027d0 D ap_hack_apr_ldap_set_option
00000000000027b0 D ap_hack_apr_ldap_ssl_deinit
00000000000027a8 D ap_hack_apr_ldap_ssl_init
0000000000002810 D ap_hack_apr_ldap_url_parse
0000000000002808 D ap_hack_apr_ldap_url_parse_ext
                 U apr_ldap_get_option
                 U apr_ldap_info
                 U apr_ldap_init
                 U apr_ldap_is_ldap_url
                 U apr_ldap_is_ldapi_url
                 U apr_ldap_is_ldaps_url
                 U apr_ldap_rebind_add
                 U apr_ldap_rebind_init
                 U apr_ldap_rebind_remove
                 U apr_ldap_set_option
                 U apr_ldap_ssl_deinit
                 U apr_ldap_ssl_init
                 U apr_ldap_url_parse
                 U apr_ldap_url_parse_ext
^ ./server/exports.o
asadmin@packaging:~/httpd24/httpd-2.4.20> 

So these apr_ldap_* references are listed as U which is undefined, hence the error. However, there are ap_hack_apr_ldap_* references that are being linked... are these wrappers of some kind? I wonder if something is trying to use these apr_ldap_* references but they are undefined, and instead should be using the ap_hack_apr_* versions which are linked. I don't really know where things are going wrong, but that is just my speculation. Any ideas?

Also, I have the openldap and openldap-devel packages installed:

asadmin@packaging:~/httpd24/httpd-2.4.20> rpm -qa | grep openldap
openldap-2.4.40-12.el6.x86_64
openldap-devel-2.4.40-12.el6.x86_64

2 个答案:

答案 0 :(得分:0)

我遇到了同样的问题。就我而言,我认为这是因为apr-util编译错误。我编译它:

./ configure --with-apr = / usr / local / apr / bin --with-ldap;使; make install;

并在尝试编译httpd时收到了您上面描述的错误。我回到了apr-util并发布了一个' make distclean'并重新执行上述步骤。 httpd然后能够编译。我认为我在apr-util上的发行版副本在以前的编译中是脏的。

答案 1 :(得分:0)

./ configure --with-apr = / usr / src / apr-1.6.3 --with-apr-util = / usr / src / apr-util-1.6.1 --enable-md --enable -http2 --enable-proxy-http2 --enable-ssl