头只图书馆"是什么增强通过&QUOT的意思;和"自动关联&rdquo ;? [英] What does Boost mean by "Header Only Libraries" and "Automatic Linking"?

查看:141
本文介绍了头只图书馆"是什么增强通过&QUOT的意思;和"自动关联&rdquo ;?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Boost库的文档页面,有两类名为头只图书馆自动链接

我料想的页眉只有库的意味着你不必对加速库,以便使用它们联系起来,而自动链接的意味着你必须联系起来。

但是当我使用 Boost.Timer ,我要链接名为定时(<$ C $静态或动态库C> libboost_timer.a 和 libboost_timer.so.1.48.0 和linux下的库路径),这显然是准确的各种软链接到这些 Boost.Timer 的库文件。我甚至需要进行链接 Boost.System Boost.Chrono ,虽然这是可以理解的库本身使用了一些需要链接其他库。

在另一边,加速明确指出, Boost.Asio的所属的自动连接,但有没有这样命名 ASIO 库文件。

所以,这是什么意思实际上是头只图书馆自动链接?或者是它纯粹是一个错误呢?

On Boost Library Documentation page, there's two categories named "Header Only Libraries" and "Automatic Linking".
I suppose "Header Only Libraries" means you don't have to link against Boost libraries in order to use them, and "Automatic Linking" means you have to link.
But when I use Boost.Timer, I have to link a static or dynamic library named timer(libboost_timer.a and libboost_timer.so.1.48.0 and various soft links to these under linux lib path), which is apparently the exact library file of Boost.Timer. I even need to link against Boost.System and Boost.Chrono, though it is understandable that the library itself uses some other libraries that need to be linked.
On the other side, Boost has clearly stated that Boost.Asio belongs to "Automatic Linking", but there's no library files named anything like asio.
So what does it actually mean to be a "Header Only Library" or "Automatic Linking"? Or is it purely a mistake?

推荐答案

正如你所说的,页眉只有库是指整个库是在头文件中,这样一个(或几个)的#include 线是足够用了。没有连接必要的。

As you said, "Header only library" means that the whole library is in header files, so one (or several) #include lines is enough to use it. No linking necessary.

自动连接的意思,虽然库需要一些链接(直接或作为一个依赖),你并不需要在编译行指定它,因为的#include 'd个文件会做一些魔术在相应的库带来自动,如果编译器所支持。

"Automatic linking" means that although the library needs some linking (either directly or as a dependency) you don't need to specify it in the compiler line, because the #include'd files will do some magic to bring in the appropriate libraries automatically, if supported by the compiler.

例如,在MSVC编译器,它们使用 #pragman评论(LIB,...);在Borland的编译器,他们使用的#pragma defineoptions ;等等。

For example, in MSVC compilers, they use #pragman comment(lib, "..."); in Borland compilers they use #pragma defineoptions; etc.

和最值得注意的是,自动连接是的不可以 GNU编译器的支持。

And most notably, "automatic linking" is not supported by the GNU compiler.

自动链接可有时麻烦(如混合调试和发布版本),可以有选择地定义一些preprocessor宏禁用它们>。在这种情况下,你必须手动进行链接。

Automatic linking can be troublesome sometimes (eg. mixing debug and release versions), you can selectively disable them by defining some preprocessor macros: BOOST_<libname>_NO_LIB. In that case you will have to do the linking manually.

更新:关于下面您的评论:

UPDATE: About your comment below:

Boost.Timer 声称自己是头只图书馆,但它在lib目录下的lib文件。

Boost.Timer claims to be a "Header only library" but it has lib files in the lib directory.

它看起来像有在提升文档错误。其实有一个名为两个不同的库的定时的:旧的,德precated,仅邮件头<一个href=\"http://www.boost.org/doc/libs/1_48_0/libs/timer/doc/original_timer.html\"><$c$c><boost/timer.hpp>而新的,改进,冷却机,自动联<一个href=\"http://www.boost.org/doc/libs/1_48_0/libs/timer/doc/cpu_timers.html\"><$c$c><boost/timer/timer.hpp>.

It looks like there is an error in the boost documentation. Actually there are two different libraries named timer: The old, deprecated, header-only <boost/timer.hpp> and the new, improved, cooler, automatically linkable <boost/timer/timer.hpp>.

但由于某些原因,主要的文档页面列出了旧的属性。

But for some reason, the main documentation page lists the properties of the old one.

有没有 Boost.Asio的 LIB文件。

在主Boost库文档页面库的文档页面,你可以看到,短耳被列为自动连接,由于依赖的。具体的依赖性列出别处:在Boost.System和Boost.Regex ,两者present自动连接。

In the main boost library documentation page library documentation page, you can see that Asio is listed as Automatic linking due to dependency. The specific dependencies are listed elsewhere: Boost.System and Boost.Regex, and both present automatic linking.

这篇关于头只图书馆&QUOT;是什么增强通过&QUOT的意思;和&QUOT;自动关联&rdquo ;?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆