Search code examples
boostboost-buildbjam

Boost.Build and <link> feature for executables


What does it exactly mean, when I pass <link>static feature to requirements section when building an executable?

exe main
       : main.cpp
         /libs//my_library
       : <library>/boost//thread
         <link>static
       ;

Does this mean that both /libs//my_library and <library>/boost//thread has to be built with static linkage?

If my target /libs//my_library has <link>static requirement set (is built only with this feature), will there be raised an error if I ommit the <link>static requirement for all targets that depends on this library (just like the one above)?


Solution

  • What does it exactly mean, when I pass <link>static feature to requirements section when building an executable?

    It means to build (and link to) the dependency libraries statically.

    exe main
           : main.cpp
             /libs//my_library
           : <library>/boost//thread
             <link>static
           ;
    

    Does this mean that both /libs//my_library and <library>/boost//thread has to be built with static linkage?

    Yes.

    If my target /libs//my_library has <link>static requirement set (is built only with this feature), will there be raised an error if I ommit the <link>static requirement for all targets that depends on this library (just like the one above)?

    No, that is OK. If your library has <link>static as a requirement, then it will be built statically no matter what, and it isn't necessary to have <link>static in a dependent target just for the sake of this library alone.

    Note that it is possible to request a specific dependency library to be built statically without affecting other dependency libraries, like this:

    exe e : /libs//mylib/<link>static /libs//otherlib /libs//someotherlib

    This <link>static above doesn't affect otherlib and someotherlib, it pertains only to mylib.