This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
problem compiling gethostbyname_r with g++
- To: gcc-help at gcc dot gnu dot org
- Subject: problem compiling gethostbyname_r with g++
- From: Kevin Su <ksu at kinaare dot net>
- Date: Mon, 18 Dec 2000 13:33:29 -0500
- References: <3A1E96AD.32DE360E@kinaare.net> <orzoiprsvn.fsf@guarana.lsd.ic.unicamp.br> <3A3E5615.27536782@kinaare.net>
Kevin Su wrote:
> >
>
> Hi,
>
> When I compile the re-entrant version of gethostbyname, gethostbyname_r(),
> with gcc, it is successfully compiled and linked.
> But if I used g++ to compile it, I got errors from undefined symbol
> __h_errno_location().
>
> The simple test program test.c and the compilation output is shown bleow.
>
> Anybody know what might be the problem here?
>
> Any help or hint is greatly appreciated.
>
> Kevin
>
> test.c
> ========================================
>
> #include <stdio.h>
> #include <netdb.h>
>
> int main(int argc, char** argv)
> {
> int h_errno;
> struct hostent *result, result_buf;
> char buf[1024];
>
> if(gethostbyname_r(argv[1], &result_buf, buf, 1024, &result, &h_errno) <
> 0){
> return -1;
> }
>
> }
>
> ======================================
>
> $ gcc test.c
> $ g++ test.c
> /tmp/ccBqm5JX.o: In function `main':
> /tmp/ccBqm5JX.o(.text+0xa): undefined reference to `__h_errno_location(void)'
>
> collect2: ld returned 1 exit status
Sorry, I forgot to mention the platform on which the problem happened:
Linux on Intel
gcc version (gcc -v):
Reading specs from /usr/lib/gcc-lib/i386-redhat-linux/egcs-2.91.66/specs
gcc version egcs-2.91.66 19990314/Linux (egcs-1.1.2 release)
Kevin