473,406 Members | 2,707 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

Problem with object file

ilikesuresh
Hi all
I wriiten the following problem to handle sockets
but when I try to compile the program It displays,

$ cc -o socket_less socket_less.c
Undefined first referenced
symbol in file
bind socket_less.o
socket socket_less.o
recvfrom socket_less.o
inet_addr socket_less.o
inet_ntoa socket_less.o
ld: fatal: Symbol referencing errors. No output written to socket_less



Program

Expand|Select|Wrap|Line Numbers
  1. #include<stdio.h>
  2. #include<sys/types.h>
  3. #include<sys/socket.h>
  4. #include<netinet/in.h>
  5. #include<arpa/inet.h>
  6. #include<string.h>
  7. #include<unistd.h>
  8. #include<stdlib.h>
  9. #define MAX_MSGLEN 100
  10. int main()
  11. {
  12.  int sock,err;
  13.  char msbuff[MAX_MSGLEN+1];
  14.  struct sockaddr_in saddr,fromaddr;
  15.  int fromaddr_len = sizeof(fromaddr);
  16.  sock = socket(AF_INET,SOCK_DGRAM,IPPROTO_UDP);
  17.  if(sock < 0)
  18.  {
  19.   perror("In socket()");
  20.   exit(1);
  21.  }
  22. saddr.sin_family = AF_INET;
  23. saddr.sin_addr.s_addr = inet_addr("127.0.0.1");
  24. saddr.sin_port = htons(61321);
  25. memset(&saddr.sin_zero,0,sizeof(saddr.sin_zero));
  26. err = bind(sock,(struct sockaddr *)&saddr,sizeof(saddr));
  27. if(err)
  28. {
  29.  perror("In Bind");
  30.  exit(1);
  31. }
  32. err = recvfrom(sock,msbuff,MAX_MSGLEN-1,0,(struct sockaddr *)&fromaddr,&fromaddr_len);
  33. if(err)
  34. {
  35.  perror("In Bind");
  36.  exit(1);
  37. }
  38. msbuff[err]='\0';
  39. close(sock);
  40. printf("Message\n\t@bytes:%d\n\t@payload:%s\n",err,msbuff);
  41. printf("Sender \n\t@arrress:%s\n\t@port:%d\n",inet_ntoa(fromaddr.sin_addr),ntohs(fromaddr.sin_port));
  42. return 0;
  43. }
  44.  
Please make it clear me...
Sep 27 '07 #1
2 1502
JosAH
11,448 Expert 8TB
Hi all
I wriiten the following problem to handle sockets
but when I try to compile the program It displays,

$ cc -o socket_less socket_less.c
Undefined first referenced
symbol in file
bind socket_less.o
socket socket_less.o
recvfrom socket_less.o
inet_addr socket_less.o
inet_ntoa socket_less.o
ld: fatal: Symbol referencing errors. No output written to socket_less



Program


#include<stdio.h>
#include<sys/types.h>
#include<sys/socket.h>
#include<netinet/in.h>
#include<arpa/inet.h>
#include<string.h>
#include<unistd.h>
#include<stdlib.h>
#define MAX_MSGLEN 100
int main()
{
int sock,err;
char msbuff[MAX_MSGLEN+1];
struct sockaddr_in saddr,fromaddr;
int fromaddr_len = sizeof(fromaddr);
sock = socket(AF_INET,SOCK_DGRAM,IPPROTO_UDP);
if(sock < 0)
{
perror("In socket()");
exit(1);
}
saddr.sin_family = AF_INET;
saddr.sin_addr.s_addr = inet_addr("127.0.0.1");
saddr.sin_port = htons(61321);
memset(&saddr.sin_zero,0,sizeof(saddr.sin_zero));
err = bind(sock,(struct sockaddr *)&saddr,sizeof(saddr));
if(err)
{
perror("In Bind");
exit(1);
}
err = recvfrom(sock,msbuff,MAX_MSGLEN-1,0,(struct sockaddr *)&fromaddr,&fromaddr_len);
if(err)
{
perror("In Bind");
exit(1);
}
msbuff[err]='\0';
close(sock);
printf("Message\n\t@bytes:%d\n\t@payload:%s\n",err ,msbuff);
printf("Sender \n\t@arrress:%s\n\t@port:%d\n",inet_ntoa(fromaddr. sin_addr),ntohs(fromaddr.sin_port));
return 0;
}

Please make it clear me...
You should've asked your question in the corresponding Forum section, not in the
Articles section; I'll move your question there for you.

kind regards,

Jos
Oct 1 '07 #2
Motoma
3,237 Expert 2GB
I have copied this thread to the C forum as well, with the hopes that the folks there may have some insight into the issue you are having.
Oct 2 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: David Blasdell | last post by:
This appears very strange to me, I'm having a problem with a fstream object inside a class which is not being called directly from main (another class calls the class that contains the fstream...
25
by: Xah Lee | last post by:
Python Doc Problem Example: gzip Xah Lee, 20050831 Today i need to use Python to compress/decompress gzip files. Since i've read the official Python tutorial 8 months ago, have spent 30...
0
by: Lyn | last post by:
I am having a frustrating time trying to do a simple insert of a BMP picture into a Bound Object Frame using both VBA and the Insert | Object... dialog. I had a separate post thread going on this...
0
by: Lokkju | last post by:
I am pretty much lost here - I am trying to create a managed c++ wrapper for this dll, so that I can use it from c#/vb.net, however, it does not conform to any standard style of coding I have seen....
2
by: Brian Cooper | last post by:
I am trying to determine a permission problem trying to write a text file from one web server to another. Here is the situation: We have two domains in place one is Active Directory and the...
10
by: Charles Law | last post by:
For some reason, when I click the X to close my MDI parent form, the action appears to be re-directed to one of the MDI child forms, and the parent remains open. I am then unable to close the...
5
by: Segfahlt | last post by:
I need a little help here please. I have 2 win forms user controls in 2 different projects that I'm hosting in 2 different virtual directories. The controls have been test and operate okay in...
6
by: TPJ | last post by:
Help me please, because I really don't get it. I think it's some stupid mistake I make, but I just can't find it. I have been thinking about it for three days so far and I still haven't found any...
3
by: =?Utf-8?B?UnVkeQ==?= | last post by:
Hello All! I may have posted this problem before, but it was awhile ago. I'm working in VS 2003. I have 10 file watch process going. It seems that I can only about 6or 7 to run at the same...
3
by: fizilla | last post by:
Hello all! I have the following weird problem and since I am new to Python I somehow cannot figure out an elegant solution. The problem reduces to the following question: How to pickle a...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.