From mboxrd@z Thu Jan 1 00:00:00 1970 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: fa528,ad93a232f2009837 X-Google-Attributes: gidfa528,public X-Google-ArrivalTime: 2001-02-03 10:21:51 PST Path: supernews.google.com!sn-xit-02!supernews.com!nntp-relay.ihug.net!ihug.co.nz!news-hog.berkeley.edu!ucberkeley!newsfeed.stanford.edu!lnsnews.lns.cornell.edu!not-for-mail From: Dan Riley Newsgroups: comp.unix.tru64 Subject: Re: c++(gcc) & gethostbyname Date: 03 Feb 2001 13:21:49 -0500 Organization: LNS, Cornell U., Ithaca, NY 14853 Sender: dsr@lns130.lns.cornell.edu Message-ID: References: <3A7AA2D0.5FCF4355@hrem.stm.tudelft.nl> NNTP-Posting-Host: lns130.lns.cornell.edu X-Trace: lnscu7.lns.cornell.edu 981224510 23273 128.84.44.116 (3 Feb 2001 18:21:50 GMT) X-Complaints-To: abuse@mail.lns.cornell.edu NNTP-Posting-Date: Sat, 3 Feb 2001 18:21:50 +0000 (UTC) X-Newsreader: Gnus v5.6.45/XEmacs 21.1 - "Big Bend" Xref: supernews.google.com comp.unix.tru64:1636 Jouk Jansen writes: > Is it a known problem that c++(gcc) cannot include gethostbyname? Works here. Some version numbers might be helpful. > focus-jj) c++ test.cpp > /usr/ucb/ld: > Unresolved: > gethostbyname(char const *) > collect2: ld returned 1 exit status There's a hint there. Consider the program extern void nosuchCC(char const*); extern "C" void nosuchc(char const*); main() { nosuchCC("asdf"); nosuchc("asdf"); } Try compiling it with c++ -- you should see something like dsr_lns130% g++ asdf.cc /usr/bin/ld: Unresolved: nosuchCC(char const *) nosuchc collect2: ld returned 1 exit status Now look back at your error message -- "gethostbyname(char const *)" means it saw a prototype, but saw it in a C++ context, so it is looking for a C++ mangled name. is supposed to take care of this via _BEGIN_CPLUSPLUS _END_CPLUSPLUS lines that are translated into extern "C" { } if __cplusplus is defined (all this in ). Your error means that for some reason this isn't happening. A 'c++ -E test.cpp' to see what the preprocessor is doing might be enlightening. -- Dan Riley dsr@mail.lns.cornell.edu Wilson Lab, Cornell University "History teaches us that days like this are best spent in bed"