Subject: Re: [Boost-build] best was to handle external libs on windows and unix
From: Vladimir Prus (ghost_at_[hidden])
Date: 2009-04-01 01:41:58
On Wednesday 01 April 2009 00:37:25 Jim Gallagher wrote:
> We are using boost-build as a build environment around customizations to a
> COTS product. We extend the product using C/C++; the vendor supplies header
> files and libraries with the product. The vendor libraries are named the
> same on windows and unix, except for the platform conventions. For example,
> on windows we may link against libfoo.lib, while on unix we link against
> The problem is that the linker behaves differently with respect to passed
> library names between windows and unix. For example, if I define libfoo like
> lib libfoo : : <name>foo <search>$(VEND_ROOT)/lib ;
> Then the link works on unix, as the linker gets passed -lfoo, and it assumes
> that there is a lib prefix. This does not work on windows, because there is
> no prefix assumption. The linker gets passed foo.lib, which fails because
> the name is really libfoo.lib.
This 'libfoo.lib' is not following windows conventions, I think, so you
need some tweaking to get this working.
> If I leave the name property off, then the link works on windows but fails
> on unix, because -llibfoo tells the linker to look for liblibfoo.so, which
> is, of course, wrong.
> Any suggestions on the best way to handle this? I have ~300 vendor libs to
> deal with....
I think the simplest approach is to write a function that will do this:
rule cots-lib ( name )
return [ searched-lib $(name)
: # No sources
: <target-os>linux:<name> $(name)
and then define libraries as:
cots-lib foo ;
cots-lib bar ;
This is probably the best approach. An alternative approach is to
- skip <name> from the metatarget declaration
- add <tag>@myname
- write myname tag rule that, for targets of SEARCHED_LIB type will
adjust the name as desired. The "Builtin features" sections of the
docs has documentation and C++ Boost Jamroot has an real usage example.
Let me know if this helps.
Boost-Build list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk