1

当我将我的 VS 项目构建为 Debug 时,它总是与 tbb_debug.lib 自动链接(它又与 tbb_debug.dll 链接)。有没有办法覆盖它并使 tbb.lib 链接,即使是 Debug 构建?

4

2 回答 2

4

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.

于 2011-09-27T07:34:11.163 回答
1

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

#pragma comment( lib, "tbb_debug" )

然后如MSDN 文档页面中所述pragma comment

在目标文件中放置一个库搜索记录。...库名称遵循目标文件中的默认库搜索记录;如果没有使用/nodefaultlib指定该库,则链接器将搜索此库,就像您在命令行上命名它一样。

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

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

于 2011-09-27T11:42:22.787 回答