0

My platform is RHEL 4.6 under intel xeon system. My compiler is gcc 4.2. All the applications are developed using C.

Let us assume I have a routine ( A ) in which I am making call which is contained in Library L. Now I have made a new library using linking statically library L with my routine A. Let us call this new library as N.

Now there are 3 different applications called X , Y and Z. All of the 3 applications need to link with the new library N.

I have tried to link ( statically ) these 3 applications with the library N. But at the time of linking why does the compiler once again give linking error if I don't include L. I have already included L at the time of making N. Still why does it expect L separately.

Soumajit
  • 95
  • 1
  • 8
  • I read this ***[link](http://www.network-theory.co.uk/docs/gccintro/gccintro_25.html)*** that goes through linking, making. (maybe it will help) In short, the files to be linked need to be present (and referenced) for all build steps. If using one, only the .dll needs to be present during runtime (i.e. no longer need static libs at that time) – ryyker Jun 19 '14 at 15:08
  • You might want to read for example: http://stackoverflow.com/questions/3821916/how-to-merge-two-ar-static-libraries-into-one – wojciii Jun 19 '14 at 15:10
  • Thank you ryyker and wojciii – Soumajit Jun 19 '14 at 15:42

1 Answers1

0

It still needs the library to build. Just because you built N doesn't mean that it put L into it. It just has the references to it. It still needs L to get a running executable. BTW, it's not a good idea to build libraries that rely on other libraries (at least other static libraries) like that.

Jiminion
  • 5,080
  • 1
  • 31
  • 54
  • Jim why does static linking still has only references within N for L. Overhauling the overall scenario would be too demanding and practically not possible. Is there a way round to solve this problem ? – Soumajit Jun 19 '14 at 15:34
  • A library is just an object, containing routines that have been compiled. It has not facility to include (compiled) code from another library. Perhaps you can rebuild the routines of N and L into one large library? I don't know why you have access to L for building N but not for later on. Also, you might be able to get farther with dynamic libraries, but at the end of the day, you still need them to run the executable. – Jiminion Jun 19 '14 at 17:31