- To: help-gcc-request at gnu dot org
- Subject: problem compiling gethostbyname_r with g++
- From: Kevin Su <ksu at kinaare dot net>
- Date: Mon, 18 Dec 2000 13:41:54 -0500
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
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