public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* Creating archive file with main
@ 2011-05-23 14:00 Ajay Jain
  2011-05-24 13:33 ` Nick Clifton
  0 siblings, 1 reply; 4+ messages in thread
From: Ajay Jain @ 2011-05-23 14:00 UTC (permalink / raw)
  To: binutils

Hi Experts,

Sorry for asking an absurd question.

1) I have a framework which includes a main and multiple 'c' files. I
need to export this framework to other sub-modules. Could I make an
archive (.a) which includes the main?

2) If not, is there any other alternative I have? Actually the
framework's output is multiple .o files and I need to export this to
various other sub-modules.

Thanks in Advance.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Creating archive file with main
  2011-05-23 14:00 Creating archive file with main Ajay Jain
@ 2011-05-24 13:33 ` Nick Clifton
  2011-05-30 13:19   ` Ajay Jain
  0 siblings, 1 reply; 4+ messages in thread
From: Nick Clifton @ 2011-05-24 13:33 UTC (permalink / raw)
  To: Ajay Jain; +Cc: binutils

Hi Ajay,

> 1) I have a framework which includes a main and multiple 'c' files. I
> need to export this framework to other sub-modules. Could I make an
> archive (.a) which includes the main?

Yes you can.

Cheers
   Nick


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Creating archive file with main
  2011-05-24 13:33 ` Nick Clifton
@ 2011-05-30 13:19   ` Ajay Jain
  2011-05-31 13:27     ` Nick Clifton
  0 siblings, 1 reply; 4+ messages in thread
From: Ajay Jain @ 2011-05-30 13:19 UTC (permalink / raw)
  To: Nick Clifton; +Cc: binutils

>> 1) I have a framework which includes a main and multiple 'c' files. I
>> need to export this framework to other sub-modules. Could I make an
>> archive (.a) which includes the main?
>
> Yes you can.

But when I combine this archive (which now has a main) with another
archive and then hope to create an executable out of it, the linker
starts cribbing.

i.e. gcc 1.a 2.a -o out
where 1.a has main complains of undefined references to crt.o

What is the missing link?

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Creating archive file with main
  2011-05-30 13:19   ` Ajay Jain
@ 2011-05-31 13:27     ` Nick Clifton
  0 siblings, 0 replies; 4+ messages in thread
From: Nick Clifton @ 2011-05-31 13:27 UTC (permalink / raw)
  To: Ajay Jain; +Cc: binutils

Hi Ajay,

>>> Could I make an archive (.a) which includes the main?
>> Yes you can.
>
> But when I combine this archive (which now has a main) with another
> archive and then hope to create an executable out of it, the linker
> starts cribbing.
 >
> i.e. gcc 1.a 2.a -o out
> where 1.a has main complains of undefined references to crt.o

This does not happen for me:

   % cat main.c
   extern int foo (void);
   int main (void) { return foo (); }

   % cat foo.c
   int foo (void) { return 1; }

   % gcc -c main.c foo.c
   % ar crv libmain.a main.o
   % ar crv libfoo.a foo.o
   % gcc libmain.a libfoo.a
   % ./a.out
   % echo $status
   1

Can you put together a full demonstration of the problem that you are 
having ?

Cheers
   Nick

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2011-05-31  9:52 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-05-23 14:00 Creating archive file with main Ajay Jain
2011-05-24 13:33 ` Nick Clifton
2011-05-30 13:19   ` Ajay Jain
2011-05-31 13:27     ` Nick Clifton

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).