libsocket

Hi,

I am having some problems with TCP/IP funcions included in library
libsocket.
My include header looks like this:
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <stdarg.h>
#include <string.h>
#include <strings.h>
#include <errno.h>
#include <netdb.h>
#include <fcntl.h>
#include <sys/time.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h


But when I try to call functions such as gethostbyname() (which is included
in netdb.h) I am told by the compiler that function.o: undefined reference
to ‘gethostbyname.’ In fact, any function in libsocket such as send, listen
has the same problem. I checked common.mk makefile that the library path
does include the path C:\QNXsdk\target\qnx6\x86\lib, where is the library
file contains. Can somebody give me a hint about what might be wrong?

Thanks,
Adam

“Adam Lee” <leeyt@gradient.cis.upenn.edu> wrote in message
news:afa2a7$9s1$1@inn.qnx.com

Hi,

I am having some problems with TCP/IP funcions included in library
libsocket.
My include header looks like this:
#include <stdio.h
#include <stdlib.h
#include <unistd.h
#include <stdarg.h
#include <string.h
#include <strings.h
#include <errno.h
#include <netdb.h
#include <fcntl.h
#include <sys/time.h
#include <sys/types.h
#include <sys/socket.h
#include <netinet/in.h
#include <arpa/inet.h


But when I try to call functions such as gethostbyname() (which is
included
in netdb.h) I am told by the compiler that function.o: undefined
reference
to ‘gethostbyname.’ In fact, any function in libsocket such as send,
listen
has the same problem. I checked common.mk makefile that the library path
does include the path C:\QNXsdk\target\qnx6\x86\lib, where is the library
file contains. Can somebody give me a hint about what might be wrong?

Try adding -lsocket, this will tell linker to link in this library. Linker
can’t figure
it out from the header files.



Thanks,
Adam

Are you linking with libsocket (-lsocket)

For instance:

CC -o myprog -lsocket myprog.cpp


Jens


“Adam Lee” <leeyt@gradient.cis.upenn.edu> wrote in message
news:afa2a7$9s1$1@inn.qnx.com

Hi,

I am having some problems with TCP/IP funcions included in library
libsocket.
My include header looks like this:
#include <stdio.h
#include <stdlib.h
#include <unistd.h
#include <stdarg.h
#include <string.h
#include <strings.h
#include <errno.h
#include <netdb.h
#include <fcntl.h
#include <sys/time.h
#include <sys/types.h
#include <sys/socket.h
#include <netinet/in.h
#include <arpa/inet.h


But when I try to call functions such as gethostbyname() (which is
included
in netdb.h) I am told by the compiler that function.o: undefined
reference
to ‘gethostbyname.’ In fact, any function in libsocket such as send,
listen
has the same problem. I checked common.mk makefile that the library path
does include the path C:\QNXsdk\target\qnx6\x86\lib, where is the library
file contains. Can somebody give me a hint about what might be wrong?

Thanks,
Adam

I tried “libsocket” instead of “socket” that’s why it didn’t work. Thanks!


“Mario Charest” postmaster@127.0.0.1 wrote in message
news:afa48d$bc3$1@inn.qnx.com

“Adam Lee” <> leeyt@gradient.cis.upenn.edu> > wrote in message
news:afa2a7$9s1$> 1@inn.qnx.com> …
Hi,

I am having some problems with TCP/IP funcions included in library
libsocket.
My include header looks like this:
#include <stdio.h
#include <stdlib.h
#include <unistd.h
#include <stdarg.h
#include <string.h
#include <strings.h
#include <errno.h
#include <netdb.h
#include <fcntl.h
#include <sys/time.h
#include <sys/types.h
#include <sys/socket.h
#include <netinet/in.h
#include <arpa/inet.h


But when I try to call functions such as gethostbyname() (which is
included
in netdb.h) I am told by the compiler that function.o: undefined
reference
to ‘gethostbyname.’ In fact, any function in libsocket such as send,
listen
has the same problem. I checked common.mk makefile that the library
path
does include the path C:\QNXsdk\target\qnx6\x86\lib, where is the
library
file contains. Can somebody give me a hint about what might be wrong?


Try adding -lsocket, this will tell linker to link in this library.
Linker
can’t figure
it out from the header files.



Thanks,
Adam
\

Adam Lee wrote:

Hi,

I am having some problems with TCP/IP funcions included in library
libsocket.
My include header looks like this:
#include <stdio.h
#include <stdlib.h
#include <unistd.h
#include <stdarg.h
#include <string.h
#include <strings.h
#include <errno.h
#include <netdb.h
#include <fcntl.h
#include <sys/time.h
#include <sys/types.h
#include <sys/socket.h
#include <netinet/in.h
#include <arpa/inet.h


But when I try to call functions such as gethostbyname() (which is included
in netdb.h) I am told by the compiler that function.o: undefined reference
to ‘gethostbyname.’ In fact, any function in libsocket such as send, listen
has the same problem. I checked common.mk makefile that the library path
does include the path C:\QNXsdk\target\qnx6\x86\lib, where is the library
file contains. Can somebody give me a hint about what might be wrong?

Thanks,
Adam
\

I had the same problem but then I compiled with the -lsocket option and
it worked.