* Re: Help needed on C++ libs
[not found] <40nmpd$t2l@infoserv.rug.ac.be>
@ 1995-08-25 4:00 ` Tim Lucia
0 siblings, 0 replies; only message in thread
From: Tim Lucia @ 1995-08-25 4:00 UTC (permalink / raw)
In article <40nmpd$t2l@infoserv.rug.ac.be>, Christophe Colle <colle> writes:
|>Hi,
|>
|>I'm new to c++. I just installed cxx and g++. When I try to compile following
|>code i get some linking errors.. When I compile I compile the C version
|>with gcc and cc, there is no error. What is wrong?
|>
|>code :
|>#include <unistd.h>
|>#include <sys/types.h>
|>#include <netinet/in.h>
|>#include <sys/time.h>
|>#include <sys/socket.h>
|>#include <arpa/inet.h>
|>#include <netdb.h>
|>
|>
|>main()
|>{
|> struct hostent *ptr=gethostbyname((char *)0l);
|>
|>}
|>
|>colle@krtkg1> g++ t.cc
|>/usr/bin/ld:
|>Unresolved:
|>gethostbyname__FPCc
|>collect2: ld returned 1 exit status
|>colle@krtkg1> cxx t.cc
|>t.cc:18: warning: The procedure "main" returns a non-void value but does not
|>contain a return statement.
|>ld:
|>Error: Undefined:
|>gethostbyname__XPCc
|>
This is due to the fact that the compiler mangled the name of 'gethostbyname'
for type-safe linkage, as described in your basic C++ text. The problem
is with netdb.h not being C++-safe on your version of the o/s. You don't
say what version of Digital UNIX you are running, by my 3.2 system has
C++-safe header files. If you only want to declare gethostbyname, then
you should say:
extern "C" {
extern struct hostent *gethostbyname __((const char *));
}
Regards,
Tim
--
Timothy J. Lucia - DECladebug Email: mailto:lucia@zko.dec.com
Digital Equipment Corporation Phone: 603.881.2615
110 Spitbrook Road ZKO2-3/K06 Fax: 603.881.0120
Nashua, NH USA 03062-2698 I'd rather be bicycling.
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~1995-08-25 4:00 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <40nmpd$t2l@infoserv.rug.ac.be>
1995-08-25 4:00 ` Help needed on C++ libs Tim Lucia
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox