This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: Fwd: Statically linking a shared library to another library to be statically linked
- From: Ian Lance Taylor <ian at airs dot com>
- To: Mohit Kumar <mohit dot kumar at gmail dot com>
- Cc: gcc-help at gcc dot gnu dot org
- Date: 01 Jun 2005 10:33:09 -0400
- Subject: Re: Fwd: Statically linking a shared library to another library to be statically linked
- References: <56c2ab680505300522f5325b9@mail.gmail.com><56c2ab68050531224329c8c2a0@mail.gmail.com>
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