ARTICLE AD BOX
I am using boost build (https://www.bfgroup.xyz/b2/tutorial.html) to build a relatively large C++ project. I am still struggling with specifying library dependencies in a concise way. From the documentation (https://www.boost.org/doc/libs/latest/tools/build/doc/html/index.html) I understand that if properly specified, the dependencies should be traced as libraries are linked together. To give a specific example that is based on my code but boiled down as much as possible, here is a Jamroot file
project : requirements <include>$(TOP) ; constant BOOST_LIB_PATH : /usr/lib/x86_64-linux-gnu ; lib boost_filesystem : : <name>boost_filesystem <search>$(BOOST_LIB_PATH) ; lib boost_system : : <name>boost_system <search>$(BOOST_LIB_PATH) ; lib boost_test : : <name>boost_unit_test_framework <search>$(BOOST_LIB_PATH) ; lib global : Wavelet.cpp boost_filesystem boost_system ; exe fileutil_test : test_fileutil.cpp global boost_test ;I would expect that boost build understands that when fileutil_test is linked, it knows that the library global needs to be linked with boost_filesystem (and boost_system) and therefore fileutil_test would also be linked to those two. At least this is my interpretation of the sentence
"When a library has a shared library as a source, or a static library has another static library as a source then any target linking to the first library with automatically link to its source library as well."
in the documentation. However, this does not seem to be the case, as I get error messages about undefined references from the linker. If I change the last line to
exe fileutil_test : test_fileutil.cpp global boost_test boost_filesystem boost_system ;everything links just fine. However, when things get more complicated (with different libraries depending on different subsets of other libraries) this becomes very tedious and I thought that this a problem that boost build is supposed to solve.
Based on various sources, I have also tried this variant
lib global : Wavelet.cpp : <library>boost_filesystem <library>boost_system ;
but with the same result.
Am I doing something wrong? Do I have wrong expectations? Any pointers are welcome
