This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC 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: Fwd: Statically linking a shared library to another library to be statically linked


Mohit Kumar <mohit.kumar@gmail.com> writes:

> Suppose I have three files: libone.a, libtwo.a and libmain.so, and I
> want to implement the followinf hierarchy:
>     libmain.so
>         |-----libtwo.a
>                    |-----libone.a
> 
> As far as linking libtwo.a to libmain.so is concerned I am aware I
> need to use '-l' flag at link time.
> But is there a way I can link a .a file to another .a file?

This is not a gcc question.  It is a binutils question.  Or a Unix
programming question.

The answer is no.  An archive is simply a collection of object files.
There is no meaningful way to link one archive to another archive.

If you will be using only the GNU linker, you could play some tricky
games with linker scripts.  For example, look at /usr/lib/libc.so on a
typical GNU/Linux system.  But I wouldn't describe that as a clean
approach.

Ian


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