How to Disable Auto-link for TBB

萝らか妹 提交于 2019-12-25 04:08:44

问题


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?


回答1:


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.




回答2:


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.



来源:https://stackoverflow.com/questions/7565089/how-to-disable-auto-link-for-tbb

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!