Bug 43822 - linker can not find res_init() (defined in resolv.h) when compiling
linker can not find res_init() (defined in resolv.h) when compiling
Status: CLOSED NOTABUG
Product: Red Hat Linux
Classification: Retired
Component: glibc (Show other bugs)
7.1
i686 Linux
medium Severity medium
: ---
: ---
Assigned To: Jakub Jelinek
Aaron Brown
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2001-06-07 07:46 EDT by Scott Sibert
Modified: 2016-11-24 09:58 EST (History)
1 user (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2001-06-08 08:41:54 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description Scott Sibert 2001-06-07 07:46:47 EDT
From Bugzilla Helper:
User-Agent: Mozilla/4.76 [en] (X11; U; Linux 2.4.2-2smp i686)

Description of problem:
here is a sample program:

char res_init();
int main() {
  res_init();
  return 0;
  }

This gives the following results (sample program is ch.c compiling to
conftest):

[sibertsa@dopey w1]$ cc -o conftest -Wall
ch.c                                 
/tmp/ccszaKJC.o: In function `main':
/tmp/ccszaKJC.o(.text+0x7): undefined reference to `res_init'
collect2: ld returned 1 exit status
[sibertsa@dopey w1]$ 

This works on RedHat 7.0 i686

How reproducible:
Always

Steps to Reproduce:
1.  See Description
2.
3.
	

Actual Results:  See Description

Expected Results:  expected sample program to compile successfully

Additional info:

This is straight RedHat 7.1 without any updates on a dual P2/300.  The RH70
machine is a dual P3/800 and has most but recent updates (just haven't
looked lately).  I've looked through the errata for RH71 and don't see
anything that would relate to this problem.
Comment 1 Jakub Jelinek 2001-06-07 07:54:42 EDT
Your example program is buggy. You should simply never define prototypes provided
by glibc, you should include proper header files instead (in this case
<resolv.h>). That will take care of making it actually __res_init which is
what glibc exports.
Comment 2 Scott Sibert 2001-06-07 09:35:30 EDT
Sample program came from a configure script; here is its reasoning behind
redefining the prototype:

/* Override any gcc2 internal prototype to avoid an error.  */
/* We use char because int might match the return type of a gcc2
    builtin and then its argument prototype would still apply.  */
char res_init();

Interesting thing is that the compile returned no errors on RH70 whereas it did
on RH71.
Comment 3 Jakub Jelinek 2001-06-07 09:49:46 EDT
Then the configure script should be fixed. There really is no res_init in glibc,
only __res_init (and res_init for binaries compiled against glibc 2.0 and
glibc 2.1).
Comment 4 Scott Sibert 2001-06-07 09:57:06 EDT
Before I make changes to the configure script, any idea why this compiles on
RH70 and not on RH71?  The configure script works correctly on RH70 and I need
to make sure I don't mess something up for another platform or RH version.
Comment 5 Scott Sibert 2001-06-08 08:41:50 EDT
The functionality of gcc or glibc (or maybe binutils) has changed.  What changed
to cause one or more to function differently than in RedHat 7.0?  Either "it now
does such-and-such" or "it no longer does such-and-such" but something has
changed functionally.  I see nothing in the Release Notes describing such
functionality change.
Comment 6 Jakub Jelinek 2001-06-10 06:17:45 EDT
res_init was deliberately removed from default symbol versions
in glibc 2.2 to show that it should not be used (programs linked
against it already will keep working, but no new programs can be
linked against it). Glibc since 2.2 uses __res_init instead, programs
which properly include <resolv.h> will compile just fine.
The autoconf test if really needed could be e.g.
test for AC_TRY_LINK_FUNC(res_init,...) and if that fails try
AC_TRY_LINK_FUNC(__res_init,...).

Note You need to log in before you can comment on or make changes to this bug.