18

什么是 Boost Jam,Jam 是否值得迁移?

我知道 jam 是 perforce 构建的构建系统,但是我不确定 boost jam 和常规 jam 有何不同。

我也希望 SO 社区中有人与它合作过,也许可以突出一些差异和/或好处。

4

4 回答 4

28

I use Boost Jam for my cross-platform C++ development. I chose it because

  • I want my code to build everywhere Boost builds,
  • it uses a relatively simple declarative language to specify how to build targets, and
  • it can build all the different flavors of your binaries (e.g. debug vs. release, 32-bit vs. 64-bit, msvc vs. gcc) in a single invocation with an absolute minimum of flavor-related exceptions in the build declarations.

You can refine generic rules with flavor-specific settings, rather than writing separate rules for each flavor permutation. The syntax isn't exactly what I would have chosen, but it's not too hard to get used to.

This paper compares Boost Jam to CMake, SCons, and Eclipse CDT: http://syrcose.ispras.ru/2009/files/04_paper.pdf

My understanding is that Boost Jam is an offshoot of Perforce Jam maintained by the Boost community, and that Perforce Jam isn't actively maintained anymore (the release notes have the last update in April 2003).

Of course, if you don't care about cross-platform development, there are easier ways to go, as others have mentioned here. Personally, I keep meaning to revisit Eclipse CDT; it didn't seem usable 5 years ago, but I hear it has come a long way.

于 2009-09-25T04:12:20.107 回答
10

正如您所说,Boost Jam 是一个构建系统,可以独立于任何其他 boost 库使用。我对 Perforce Jam 一无所知,但据我了解,Boost jam 非常相似,而且大多兼容。

The main difference is that Boost Jam often comes with Boost Build, a collection of jam rules designed for common tasks, e.g. compiling libraries, running unit tests, creating doxygen documentation, etc.

Compared to other build systems, Boost Jam/Boost Build is designed for easily compilation of different variants. So if you want to change compilation settings from debug to release, or single- to multi-threaded, it determines a lot of the changes automatically.

The drawback is that the syntax is very finicky, and outside the boost website, there's no good documentation. But I imagine Perforce Jam is just as bad in that regard.

于 2009-03-18T14:47:46.233 回答
10

Given the choice of build tools I would not migrate to jam. There are better build systems out there - CMake / SCons for C/C++, qmake for Qt, Ant for Java, NAnt and MSBuild for .NET, and so on. They might not be technically superior but they will be less painful to use simply because far more people are familiar with them (on the other hand, they might be technically superior, of course :D).

于 2009-03-18T15:00:59.260 回答
5

出于我的目的,它只是为您构建 boost 库的东西,我不知道您可以用它做任何其他事情,所以我不明白迁移到它意味着什么。我很抱歉,但我不知道普通果酱是什么。由于没有其他人提供答案,我只提供我对它的理解。

Boost 是 C++ 的类和函数的集合,可用于各种任务。boost 的类和函数被分组到库中。一些库的所有代码都在头文件中,您可以通过使用#include 预处理器语句简单地使用它们,而其他库(例如文件系统或正则表达式库)在 .cpp 文件中具有部分实现。

编译这些 .cpp 文件可能需要很长时间(大约需要 30 分钟,具体取决于您正在编译的内容),如果每次您想重新编译程序都需要半个小时,那将是一个真正的痛苦。所以他们所做的只是对那些部分存储在.cpp文件中的库,你可以将它们预编译成.lib文件,这就是boost jam的目的。这意味着你只需要花半个小时编译一次,从那以后你再也不用等半个小时了。

然而,正如你可以想象的那样,每个 boost 库都由许多 cpp 文件和许多头文件组成,并且每个文件都有许多不同的风格(调试版本、发布版本、多线程等),因此这不是一个简单的过程只需自己编译 boost 库。这就是 boost jam 的用武之地。你给它编译库的命令,然后它为你发出所有命令给编译器,到最后,你将拥有一组预编译的 .lib 文件,其中一个用于每个库的每种不同风味。头文件以某种方式告诉链接器要包含哪些 lib 文件,因此如果您设置了正确的路径,预编译的 .lib 文件的正确风格将自动链接到您的程序,从而为您节省 30 分钟的编译时间。

您可以通过查看此页面了解 boost jam 需要编译哪些库以及不需要编译哪些库:http: //www.boost.org/doc/libs/1_37_0 - 如果库不需要 lib 文件(因此不需要你先搞砸 boost jam),它会说“Build & Link: Header only”,而如果一个库确实需要你预编译一个 lib 文件,它会说“Build & Link: Automatic linking”。

此外,如果您使用的是 Windows,则可以下载预编译的 .lib 文件,这样您就不必使用 boost jam。为此,您应该访问 www.boost.org 页面,转到“入门”部分并一直遵循它,以确保您已正确设置所有内容。该页面的 Windows 版本上的链接之一告诉您在哪里可以找到预编译的 .lib 文件。

于 2009-02-08T22:57:39.210 回答