Mailing List
Home
Forum Home
Linux - General Red Hat Linux discussion list
Enterprise Linux 3 - Discussion of Red Hat Enterprise Linux 3 (Taroon)
Installation - Getting started with Red Hat Linux
Red Hat Linux 9 - Discussion of Red Hat Linux 9 (Shrike)
Red Hat Linux 7.3 - Discussion of Red Hat Linux 7.3 (Valhalla)
Red Hat Linux 7.2 - Discussion of Red Hat Linux 7.2 (Enigma)
Apache Web Server
Oracle database, Microsoft SQL server ...
Subjects
application/x mplayer2 plugin
RPM error: db4 error(16) from dbenv >remove: Device or resource
   busy
Command stream end of file while reading
X Windows problem (xauth)
Upgrading openoffice 1 1 rpm
FTP: connection refused
FTP: connection refused
mount: /dev/cdrom: is not a valid block device
Dell Precision 650, RedHat 9, no sound
how to trace the cause resulting in the crash of bind server
Virus on the list
UNINSTALL RPM MYSQL
usb pen drives: mounting as a user
broadcom network interface
make mrproper
sendmail configuration on redhat
Couldn 't open PID file /var/run/named/named pid Permission denied
Promise 378 controller
kernel 2 6 and /dev/sound/mixer not found
Problem using up2date
mrtg step by step howto/configuration for a newbie?
Compiling and Installing Kernel 2 6
Can 't locate module ppp0, can 't locate module ppp compress 21
HOW I CAN MAKE BOOTABLE FLOPPY DISKET
Lotus Notes under Wine
/etc/security/limits conf question
Intel E/1000 driver
Command stream end of file while reading
rpm database corrupt
qla2300 modules
 
Search:  
Power your search with and, or, +, -, or "some phrase" operators.
ns_initparse link problem

ns_initparse link problem

2003-05-13       - By Eric Koldeweij

 Back
ppl,

Can someone help me out with the following problem?
The problem is that when I try to compile a program which queries name
servers, it fails at the linking stage with the message "undefined
reference to `__ns_initparse'" and I cannot understand why. Here's the info:

[eric@(protected) gethostinfo]$ gcc -Wall -g -o gethostinfo gethostinfo.c
-lresolv
/tmp/ccX1YbrX.o: In function `main':
/home/eric/src/gethostinfo/gethostinfo.c:41: undefined reference to
`__ns_initparse'
collect2: ld returned 1 exit status
[eric@(protected) gethostinfo]$ strings --print-file-name /lib/*|grep
ns_initparse
/lib/libresolv-2.2.4.so: __ns_initparse
/lib/libresolv-2.2.4.so: ;; ns_initparse: %s
/lib/libresolv.so.2: __ns_initparse
/lib/libresolv.so.2: ;; ns_initparse: %s

So... I am linking against the resolver library, according to what I see
the ns_initparse function is in there and yet it cannot find it.....
Same is the case for other functions like ns_parserr() etc. What's the
catch here?

I'm using standard RedHat issue glibc-2.2.4-32 and gcc-2.96-112.7.2.
Compiling using gcc version 3 (gcc3-3.0.4-1) gives exactly the same results:

[eric@(protected) gethostinfo]$ gcc3 -Wall -g -o gethostinfo gethostinfo.c
-lresolv
/tmp/ccSWrvut.o: In function `main':
/home/eric/src/gethostinfo/gethostinfo.c:41: undefined reference to
`__ns_initparse'
collect2: ld returned 1 exit status

I'm clueless, who knows what is going on here?

To make things complete, here's the source code, try for yourself:

-- ---- ---- ---- ----- start source -- ---- ---- -----
#include <stdio.h>
#include <string.h>
#include <netinet/in.h>
#include <netdb.h>
#include <arpa/nameser.h>
#include <resolv.h>

/* #include "iso3166.h" */

#define BUFLEN    1024

char queryname[BUFLEN];
char answer[BUFLEN];

int main(int arg, char *argv[])
{
   ns_msg handle;
   int anslen;

   strcpy(queryname,argv[1]);
   /*
   if (!getqueryname(argv[1]) || !(*queryname))
   {
       fprintf(stderr,"Could not find IP address for %s\n",argv[1]);
       return 1;
   }
   */

   if (res_init() < 0)
   {
       fprintf(stderr,"Could not initialize resolver, exiting\n");
       return 2;
   }

   if ((anslen = res_search(queryname,C_IN,T_A,answer,BUFLEN)) == -1)
   {
       herror("DNS query failed");
       return 3;
   }

   ns_initparse(answer,anslen,&handle);

   return 0;
}
-- ---- ---- --- end source -- ---- ---- --
(As you can obviously see, this program is not finished yet. without the
ns_initparse I do get something back from the name server)




Earn $52 per hosting referral at Lunarpages.