Mail Archives: cygwin/2005/06/16/22:59:35
Hello all,
I'm trying to use the function inet_pton(), but I found the following error
when trying to build the application with Eclipse/CDT on Cygwin:
(I apologize in advance if this is not a Cygwin related problem. It's simply
that I saw a post in which it was mentioned that inet_pton() wasn't
supported by Cygwin...)
ERROR:
make -k clean all
rm -f newclient.o newserver.o test.o
gcc -c -o newclient.o newclient.c
gcc newclient.c -o newclient
/cygdrive/f/DOCUME~1/FERNAN~1/LOCALS~1/Temp/ccqoLn6M.o(.text+0xae):newclient.c:
undefined reference to `_inet_pton'
collect2: ld returned 1 exit status
make: *** [newclient] Error 1
gcc -c -o newserver.o newserver.c
gcc newserver.c -o newserver
gcc -c -o test.o test.c
gcc test.c -o test
make: Target `all' not remade because of errors.
As you can see, it seems that the library is misson or something.., but I
did include it..
CODE:
#include <stdlib.h>
#include <netinet/in.h>
#include <arpa/inet.h> // inet_pton() reference...?
#include <sys/socket.h>
#include <string.h>
#include <stdio.h>
int main(int argc, char **argv)
{
int sockfd; // socket file descriptor
struct sockaddr_in servaddr; // IPv4 socket address structure
//sockfd = socket(AF_INET, SOCK_STREAM, 0); // call to socket function
printf("Connecting to socket...");
if ( (sockfd = socket(AF_INET, SOCK_STREAM, 0)) < 0)
printf("Socket Error");
bzero((char *) &servaddr, sizeof(servaddr)); // initialization of socket
structure to 0
servaddr.sin_family = AF_INET;
servaddr.sin_port = htons(/*9877*/13); // Port in host byte order must be
converted
// to network byte order
if (inet_pton(AF_INET, argv[1], &servaddr.sin_addr) <= 0)
printf("\ninet_pton error");
if (connect(sockfd,( struct sockaddr *) &servaddr, sizeof(servaddr)) < 0)
printf("\nError connecting to server!");
// Connection to port 9877, IP?
exit(0);
}
Any idea?
Thanks,
FBM
--
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
Problem reports: http://cygwin.com/problems.html
Documentation: http://cygwin.com/docs.html
FAQ: http://cygwin.com/faq/
- Raw text -