This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

problem compiling gethostbyname_r with g++


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]