LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Slackware (https://www.linuxquestions.org/questions/slackware-14/)
-   -   libwrap: hosts_ctl undefined reference. (https://www.linuxquestions.org/questions/slackware-14/libwrap-hosts_ctl-undefined-reference-4175608633/)

GazL 06-26-2017 06:39 AM

libwrap: hosts_ctl undefined reference.
 
Code:

build@ws1:/tmp/gophernicus-2.5$ make
make[1]: Entering directory '/tmp/gophernicus-2.5'
make EXTRA_CFLAGS="-DHAVE_LIBWRAP" EXTRA_LDFLAGS="-lwrap" in.gophernicus
make[2]: Entering directory '/tmp/gophernicus-2.5'
gcc  -lwrap gophernicus.o file.o menu.o string.o platform.o session.o options.o -o in.gophernicus
gophernicus.o: In function `main':
gophernicus.c:(.text.startup+0x604): undefined reference to `hosts_ctl'
collect2: error: ld returned 1 exit status
make[2]: *** [Makefile:89: in.gophernicus] Error 1
make[2]: Leaving directory '/tmp/gophernicus-2.5'
make[1]: *** [Makefile:65: withwrap] Error 2
make[1]: Leaving directory '/tmp/gophernicus-2.5'
make: *** [Makefile:56: all] Error 2
build@ws1:/tmp/gophernicus-2.5$ readelf -s /usr/lib64/libwrap.a | grep hosts_ctl
File: /usr/lib64/libwrap.a(hosts_ctl.o)
    1: 0000000000000000    0 FILE    LOCAL  DEFAULT  ABS hosts_ctl.c
    9: 0000000000000000  141 FUNC    GLOBAL DEFAULT    1 hosts_ctl
build@ws1:/tmp/gophernicus-2.5$

I can build without libwrap support, but that's not really the point, I'm confused. Explain please.

Alien Bob 06-26-2017 07:48 AM

I think this happens because the static library containing the symbol is on the commandline (-lwrap) before the object that needs it (gophernicus.o). If you reverse the two, it should work.

knudfl 06-26-2017 07:49 AM

Quote:

undefined reference to `hosts_ctl'
Happens with no /usr/lib64/libwrap.so

There's a patch for "shared libwrap": tcp_wrappers-7.6-shared_lib_plus_plus-1.patch
http://www.linuxfromscratch.org/patc...s_plus-1.patch

Example, tcp_wrappers-7.6
Code:

tar xvf tcp_wrappers_7.6.tar.gz
ftp://ftp.porcupine.org/pub/security...ers_7.6.tar.gz
cd tcp_wrappers_7.6/
patch -p1 < tcp_wrappers-7.6-shared_lib_plus_plus-1.patch
make
# make install
# cd /usr/lib/
# mv libwrap.so* ../lib64/

P.S.: gophernicus-2.5 will build with libwrap by using plain 'make' (No options required.)

-

GazL 06-26-2017 09:22 AM

Quote:

Originally Posted by Alien Bob (Post 5727274)
I think this happens because the static library containing the symbol is on the commandline (-lwrap) before the object that needs it (gophernicus.o). If you reverse the two, it should work.

Yes, thank you Eric, It is indeed the order. Swapping the order around in the makefile got me a little further on, but failed with:
Code:

/usr/lib64/gcc/x86_64-slackware-linux/7.1.0/../../../../lib64/libwrap.a(hosts_access.o): In function `host_match':
hosts_access.c:(.text+0x625): undefined reference to `yp_get_default_domain'

Adding -lnsl got around that one, and it now builds properly.

I'm afraid the author of this isn't very good at makefiles, in fact it's pretty damn horrid.


aside: Does one get away with this mis-ordering when using .so's? because it's not something I've ever run into before, and I'm pretty sure I've commonly seen libraries listed first on compiler invocations.

Alien Bob 06-26-2017 09:24 AM

This is typical when using code from static libraries.


All times are GMT -5. The time now is 12:33 PM.