libsocket

bridged with qdn.public.devtools
Post Reply
Adam Lee

libsocket

Post by Adam Lee » Tue Jun 25, 2002 3:36 pm

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

Mario Charest

Re: libsocket

Post by Mario Charest » Tue Jun 25, 2002 4:09 pm

"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

Jens H Jorgensen

Re: libsocket

Post by Jens H Jorgensen » Tue Jun 25, 2002 4:10 pm

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

Adam Lee

Re: libsocket

Post by Adam Lee » Tue Jun 25, 2002 4:38 pm

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



Konstantinos

Re: libsocket

Post by Konstantinos » Thu Apr 17, 2003 2:47 pm

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.

Post Reply

Return to “qdn.public.devtools”