sadhanavs <[EMAIL PROTECTED]> wrote:          yes I did it in extern_file.c

--- In [email protected], "Brett McCoy" <[EMAIL PROTECTED]> wrote:
>
> On 10/4/07, sadhanavs <[EMAIL PROTECTED]> wrote:
> 
> > I have two files extern_function.c and extern_file.c.
> >
> > // extern_file.c
> >
> > int x =20;
> > int getData()
> > {
> > return 20;
> > }
> >
> > // extern_function.c
> >
> > extern int getValue();
> > extern int k;
> > int main()
> > {
> >
> > printf("%d\n", getValue());
> > getInput();
> > return 0;
> >
> > }
> >
> > int getInput(){
> > printf(" Value:-%d ",k);
> > return 0;
> > }
> 
> 
> I don't see anywhere where you define k. You declare it with extern
> which means the compiler is expecting it to be defined somewhere else.
> Did you mean int k = 20 in the first file?
> 
> > i compile it using gcc.
> >
> > gcc extern_file.c extern_function.c
> > Undefined first referenced
> > symbol in file
> > k /var/tmp//ccctm19K.o
> > ld: fatal: Symbol referencing errors. No output written to a.out
> > collect2: ld returned 1 exit status
> >
> > Why is that the function getValue() works with extern and not k?
> > I commented out the printf("%d",k);
> > Is there something else i need in order to get the object files
linked?
> >
> > Thanks
> > Sadhana
> >
> >
> >
> > To unsubscribe, send a blank message to
<mailto:[EMAIL PROTECTED]>.
> > Yahoo! Groups Links
> >
> >
> >
> >
> 
> 
> -- 
> ----------------------------------------------------------
> "In the rhythm of music a secret is hidden;
> If I were to divulge it, it would overturn the world."
> -- Jelaleddin Rumi
>



 
   
  hai,
  this is uday.i have seen ur question.i got ur point.but the u better try 
returning x instead of 20 directly in first file.ok.any way nice meeting u.u 
know i have one more sadhana who is my best friend in the world.actually  i 
thought that she has mailed .but after seeing ur mail & mail id i 
understood.may i know from which place u r?what is ur qualuification?anyway see 
u later.
  byeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee
   
  
 

       
---------------------------------
 Save all your chat conversations. Find them online.

[Non-text portions of this message have been removed]

Reply via email to