This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Creating archive file with main


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]