如何禁用 TBB 的自动链接

发布于 2024-12-07 03:27:58 字数 103 浏览 0 评论 0原文

当我将 VS 项目构建为“调试”时,它总是自动与 tbb_debug.lib 链接(反过来又与 tbb_debug.dll 链接)。有没有办法覆盖它并使 tbb.lib 链接甚至对于调试版本?

When I build my VS project as Debug, it always auto-linked with tbb_debug.lib (which in turn linked with tbb_debug.dll). Is there a way to override this and make tbb.lib linked even for a Debug build?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

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

评论(2

影子的影子 2024-12-14 03:27:58

首先,您确定它是“自动链接”吗?

如果是这样,则可以使用#pragma comment(lib, tbb_debug.lib)来完成。找到该代码的位置,如果是您的,则修改它,或者以某种方式禁用它(通过不包含该代码所在的文件,或者通过 #defining 禁用这段代码的内容;任何理智的库编写者都应该提供这样的机制并且也应该清楚地记录下来)。

如果没有这样的编译指示,则会链接该库,因为它出现在项目设置中。右键项目->属性->链接器->输入并调整。

编辑感谢Alexey的评论,看来您可以禁用TBB的自动链接,如

First, are you sure it is 'auto-linked'?

If so, this is done using #pragma comment( lib, tbb_debug.lib ). Find where this code is, modify it if it's yours, or else disbale it somehow (either by do not including the file where that code is, or by #defining something that disables this piece code; any sane library writer should provide such a mechanism and it should be documented clearly as well).

If there is no such pragma, the library is linked because it appears in the project settings. Right-click project->Properties->Linker->Input and adjust.

Edit thanks to Alexey's comment it seems that you can probably disable TBB's autolinking, as seen in this header file. Defining __TBB_NO_IMPLICIT_LINKAGE should do the trick.

倾其所爱 2024-12-14 03:27:58

如果与 tbb_debug.lib 的自动链接是通过以下方式完成的:

#pragma comment( lib, "tbb_debug" )

则如 pragma comment 的 MSDN 文档页面:

将库搜索记录放入目标文件中。 ...库名称遵循目标文件中默认的库搜索记录;链接器会搜索此库,就像您在命令行中命名它一样,前提是未使用 /nodefaultlib

您可以通过传递链接器选项 /NODEFAULTLIB:tbb_debug.lib,通过 #pragma comment( lib, "tbb_debug" ) 禁用自动链接。

但是,您问这个问题是因为您收到“多重定义符号”错误 (LNK1169) 还是 LNK4098?如果是这样,您可能已将 tbb.lib 列为调试和发布配置文件的链接器的输入。您应该删除调试配置文件的此条目,因为会自动链接到正确的库。

If the autolinking with tbb_debug.lib is accomplished with:

#pragma comment( lib, "tbb_debug" )

then as explained on the MSDN documentation page for pragma comment:

Places a library-search record in the object file. ... The library name follows the default library-search records in the object file; the linker searches for this library just as if you had named it on the command line provided that the library is not specified with /nodefaultlib.

You could disable the autolinking via #pragma comment( lib, "tbb_debug" ) by passing the linker option /NODEFAULTLIB:tbb_debug.lib.

However, are you asking because you are receiving a "multiply defined symbols" error (LNK1169) or perhaps LNK4098? If so, it may be that you have tbb.lib listed as input to linker for both Debug and Release profiles. You should remove this entry for the Debug profile as the correct library is being automatically linked in.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文