LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices


Reply
  Search this Thread
Old 06-26-2017, 06:39 AM   #1
GazL
LQ Veteran
 
Registered: May 2008
Posts: 6,894

Rep: Reputation: 5014Reputation: 5014Reputation: 5014Reputation: 5014Reputation: 5014Reputation: 5014Reputation: 5014Reputation: 5014Reputation: 5014Reputation: 5014Reputation: 5014
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.
 
Old 06-26-2017, 07:48 AM   #2
Alien Bob
Slackware Contributor
 
Registered: Sep 2005
Location: Eindhoven, The Netherlands
Distribution: Slackware
Posts: 8,559

Rep: Reputation: 8106Reputation: 8106Reputation: 8106Reputation: 8106Reputation: 8106Reputation: 8106Reputation: 8106Reputation: 8106Reputation: 8106Reputation: 8106Reputation: 8106
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.
 
2 members found this post helpful.
Old 06-26-2017, 07:49 AM   #3
knudfl
LQ 5k Club
 
Registered: Jan 2008
Location: Copenhagen DK
Distribution: PCLinuxOS2023 Fedora38 + 50+ other Linux OS, for test only.
Posts: 17,511

Rep: Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641
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.)

-

Last edited by knudfl; 06-26-2017 at 07:40 PM.
 
1 members found this post helpful.
Old 06-26-2017, 09:22 AM   #4
GazL
LQ Veteran
 
Registered: May 2008
Posts: 6,894

Original Poster
Rep: Reputation: 5014Reputation: 5014Reputation: 5014Reputation: 5014Reputation: 5014Reputation: 5014Reputation: 5014Reputation: 5014Reputation: 5014Reputation: 5014Reputation: 5014
Quote:
Originally Posted by Alien Bob View Post
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.
 
Old 06-26-2017, 09:24 AM   #5
Alien Bob
Slackware Contributor
 
Registered: Sep 2005
Location: Eindhoven, The Netherlands
Distribution: Slackware
Posts: 8,559

Rep: Reputation: 8106Reputation: 8106Reputation: 8106Reputation: 8106Reputation: 8106Reputation: 8106Reputation: 8106Reputation: 8106Reputation: 8106Reputation: 8106Reputation: 8106
This is typical when using code from static libraries.
 
  


Reply

Tags
gophernicus-2.5, libwrap


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
C++ undefined reference grob115 Programming 4 01-22-2013 11:22 AM
undefined reference to.... crapodino Programming 1 01-13-2008 07:05 PM
undefined reference? Sharky01252 Programming 3 11-07-2006 11:36 AM
Undefined Reference ChemicalBurn Programming 2 02-14-2005 03:01 AM
undefined reference mp4-10 Programming 3 01-25-2005 12:38 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware

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

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration