Hi,
I have problems to compile a demo-program, which I get.
If I try to compile it, I get the following error-messages :
undefined reference to ‘socket’
undefined reference to ‘bind’
undefined reference to ‘recvfrom’
undefined reference to ‘inet_ntoa’
I use this gcc- call to compile : gcc listener listener.c
The Code is the following :
/*
** listener.c - a datagram sockets “server” demo
*/
:
:
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
:
:
int main(void) {
:
if ((sockfd = socket(AF_INET, SOCK_DGRAM, 0)) == -1) {
perror(“socket”);
exit(1);
}
:
if (bind(sockfd, (struct sockaddr *)&my_addr, sizeof(struct sockaddr)) == -1) {
perror(“bind”);
exit(1);
}
:
if ((numbytes=recvfrom(sockfd,buf, MAXBUFLEN-1, 0,
:
printf(“got packet from %s\n”,inet_ntoa(their_addr.sin_addr));
:
close(sockfd);
return 0;
}
I think I have to configure the gcc such that it knows where the header-files are, but how can I do this ? I use QNX 6.2
I hope someone can help me,
Tobias