[openbeos] Re: jam issues

  • From: Ingo Weinhold <bonefish@xxxxxxxxxxxxxxx>
  • To: openbeos@xxxxxxxxxxxxx
  • Date: Tue, 10 Aug 2004 23:53:52 +0200

On 2004-07-06 at 03:01:20 [+0200], Gabe Yoder wrote:
> Okay, this should be a pretty easy question for our jam gurus.  I have a
> directory where the stuff that I build needs to link in a static library
> produced in a neighboring directory.  The static library is built using the
> StaticLibrary rule, and I try to link using a rule like
> LinkStaticOSLib foo : libbar.a ;
> (I am writing this from memory, so I might be a little off).
> 
> When I build, gcc complains that it can't find libbar.a.  I checked in the
> objects directory and traverse down the tree to find that libbar.a exists in
> the directory corresponding to its source directory.  I then tried
> specifying ../bar/libbar.a instead of just libbar.a, and that didn't work
> either.  Clearly, I need to do something so that it knows where to get the
> library.  How can I get it to link in my library?

The most simple answer to the last question (in the thread similar things 
have been proposed) is to use the LinkSharedOSLibs rule. Always use this rule 
directly or indirectly (rules like Addon, App, BinCommand etc. have a 
parameter that is just passed to LinkSharedOSLibs). Obviously the rule is 
misnamed, but it will be renamed to LinkAgainst in the next incarnation of 
the build system (I'm positive that we'll see it later this year :-).

Regarding why LinkStaticOSLibs doesn't work: Unlike LinkSharedOSLibs it just 
hasn't been maintained and remained quite naive. It simply prepends a `-l' to 
the supplied parameter and passes it to the linker. So you would need to a) 
give it `foo' as parameter and b) take care that the directory it lives in is 
added to the library search path of the linker. But that still wouldn't be 
perfect in case the static library is a generated build system target (as in 
your case), since the dependency would not be added. LinkSharedOSLibs on the 
other hand handles all this gracefully: It figures whether the parameter is a 
build system target or not and takes the appropriate action.

CU, Ingo

PS: I removed LinkStaticOSLibs from Jamrules; it hasn't been used anyway.

Other related posts: