Building basic Boost applications with bjam

Building basic Boost applications with bjam

甜柠檬 发布于 2021-11-28 字数 496 浏览 930 回复 2 原文

I can find tons of general purpose documentation on Boost.Build, but surprisingly nothing on how to use it to build simple Boost applications.

I compiled Boost for mingw with bjam, got all the libraries and includes in C:Boost. Now what would a basic Jamroot file look like to use all this ?

The libs all have complicated names like 'libboost_filesystem-mgw34-mt-s.lib', I'm sure there is some kind of magic switch somewhere to just say 'link against libboost_filesystem' !

如果你对这篇文章有疑问,欢迎到本站 社区 发帖提问或使用手Q扫描下方二维码加群参与讨论,获取更多帮助。

扫码加入群聊

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

尐偏执 2022-06-07 2 楼

It's not necessary in any way to use bjam in order to build code that works with boost.

Thus, use gmake, or batch scripts, or an IDE, or whatever you like. bjam is one of the harder choices as like you've found, the documentation is poor.

There is a very basic tutorial at:

http://www.boost.org/doc/libs/1_39_0/more/getting_started/unix-variants.html

or

http://www.boost.org/doc/libs/1_39_0/more/getting_started/windows.html

戈亓 2022-06-07 1 楼

Of course there are shortcuts! An example project could look like:

#jamfile - an example Boost.Build project
exe my_exe : [ glob *.cpp ] /boost//filesystem ;

Making an executable from all .cpp files in the project's directory and using Boost.Filesystem.
Then you don't need to build any of boost libraries manually, bjam will take care of that itself as necessary. That will also ensure your app always links with the boost libraries compiled with the right options.
There is some initial configuration effort to be done to prepare an environment for using Boost.Build, such as creating a user-config.jam, a boost-build.jam and a jamroot for convenience (having e.g. use-project /boost : /path/to/boost statement). But that's a one-time effort and after that things are much easier than before.
http://www.boost.org/boost-build2/doc/html/index.html