Hi Gaurav,

I've looked at the problem, and I think I know what is going on. It's really
an issue with C/C++ linkage. The project you sent is in C++. The problem is
that NetSocket.lib and NetSocket.c is in C. Because of the differences in C
and C++ linkage (C++ mangles function names, C doesn't), the linker cannot
link in gethostname (). The solution is to wrap an 'extern "C"' around the
declaration of gethostname (); this tells the compiler to use C linkage for
gethostname (). Open sys_socket.h, and look for the declaration of
gethostname () - in line 284 or so. Modify it to look like this:

/* lets the compiler know to use C linkage if C++ is being used */
#ifdef __cplusplus
extern "C"{
#endif

SWord  gethostname(CharPtr nameP, SWord namelen);

#ifdef __cplusplus
}
#endif

This should fix the problem in your project. Hope this helps.

Rgds,
Jun-Kiat Lam
Metrowerks Technical Support

----- Original Message -----
From: J. Klapste <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Wednesday, November 10, 1999 11:14 AM
Subject: Re: problem in NetSocket.lib


>
>
> I took a quick look at two projects that I had done under CW 5.x. If I was
> using berkley socket type functionality, or NETU*() calls as you are, I
> was including NetSocket.c. If I was using the Networking API without
> berkley type functionality, I was NOT including NetSocket.c. In neither
> case am I not including any libraries besides StartupCode.lib.
>
> In the situation you listed below, getting the link error for gethostname
> undefined, you were NOT including NetSocket.c, correct? If you remove it,
> and include NetSocket.c does everything compile correctly?
>
> -J
>
> On Wed, 10 Nov 1999, Gaurav Palvia wrote:
>
> > yes it works but then what is the use of that lib.infact all the
functions
> > are there in the NetSocket.c
> > -----Original Message-----
> > From: J. Klapste <[EMAIL PROTECTED]>
> > To: palm-dev-forum <[EMAIL PROTECTED]>
> > Date: Wednesday, November 10, 1999 9:40 PM
> > Subject: Re: problem in NetSocket.lib
> >
> >
> > >
> > >Did you add NetSocket.c to your project? I believe gethostname resides
> > >there, and not in the library.
> > >
> > >On Tue, 9 Nov 1999, Gaurav Palvia wrote:
> > >
> > >> hi pals ,
> > >>    today i tried to use NetSocket.lib given in the Palm SDK.I created
an
> > app
> > >> that  works as an echoclient.
> > >>
> > >>  i went into the Project menu and using menu item Add Files i added
> > >> this NetSocket.lib in my AppSources. In my app i included
> > >> sys_socket.h and  i used the following wo functions from this library
> > >> 1>NetUTCPOpen
> > >> 2>NetUReadN
> > >> 3>NetUWriteN
> > >> 4> gethostname
> > >> but when i MAKE my application it gives me the following error for
each
> > >> function:
> > >>
> > >> eg:
> > >> starter.cpp:  gethostname referenced from MainFormEventHandler is
> > undefined.
> > >>
> > >> i dont understand what is the problem.as whenever i try to use any
> > function
> > >> which has been defined in NetSocket.c it gives me the above error.
> > >>
> > >> is there any problem in the way i have included the NetSocket.lib
file.if
> > so
> > >> please
> > >> tell me how to  use a custom built library file in your project.
> > >>
> > >> i will be highly grateful to u for this act of kindness.
> > >>
> > >>
> > >>
> > >>
> > >
> >
> >
>
>

Reply via email to