从 .lib 到另一个 .lib 的依赖关系
我正在尝试使用 Intel TBB 和 IPP 构建 OpenCV v2.3.1。我使用 CMake 生成 Visual Studio 2010 解决方案。构建成功,输出中有 opencv_core231d.lib 。
现在我尝试将 opencv_core231d.lib 与我的项目链接。但是,在 Linker -> 中指定后,其他依赖项,我收到错误 LNK1104:无法打开文件“tbb_debug.lib”。
这不是关于未解决的外部的错误。链接器想要我提供特定的 .lib 文件!怎么可能呢?
我已经完成了 opencv_core231d.lib 的 dumpbin /all ,它告诉我几个部分:
Linker Directives
-----------------
...
/DEFAULTLIB:"tbb_debug.lib"
...
我尝试将 tbb_debug.lib 添加到我的项目的 /NODEFAULTLIB 链接器选项中,它解决了问题。但是,我只想将 TBB 链接到 opencv_core231d.lib 中。
奇怪的是我找不到将 tbb_debug.lib 添加到 opencv_core231d.lib 的 /DEFAULTLIB 选项的任何原因。我已经搜索了解决方案目录中提到 tbb_debug.lib 作为子字符串的所有文件,但唯一的匹配项是生成的 .obj 和 .lib 文件 - 而不是任何源文件或项目文件。魔力在哪里?
这个问题不仅与 OpenCV 有关,而且与使用 .lib 文件的整个过程有关。
更新
TBB包含文件_tbb_windef.h中有一个#pragma comment(lib, "tbb_debug.lib")
指令,所以现在我可以理解它去了哪里。
我仍然不明白的是为什么它没有在 opencv_core231d.lib 中静态链接?我已设置图书管理员 ->将“链接库依赖项”选项设置为“是”。我的项目中没有 #pragma comment(lib, "tbb_debug.lib") 指令 - 我已经检查了预处理器输出。
谢谢。
I'm trying to build OpenCV v2.3.1 using Intel TBB and IPP. I used CMake to generate Visual Studio 2010 solution. Build is successful and I have opencv_core231d.lib among output.
Now I'm trying to link opencv_core231d.lib with my project. However, after specifying it in Linker -> Additional dependencies, I receive error LNK1104: cannot open file 'tbb_debug.lib'.
That's not the error about unresolved externals. Linker wants specific .lib file from me! How can that be?
I've done dumpbin /all
of opencv_core231d.lib and for several sections it tells me:
Linker Directives
-----------------
...
/DEFAULTLIB:"tbb_debug.lib"
...
I tried to add tbb_debug.lib to /NODEFAULTLIB linker option of my project and it solved the problem. However, I just want TBB to be linked in opencv_core231d.lib.
The strange thing is I cannot find any reason why tbb_debug.lib is added to /DEFAULTLIB option of opencv_core231d.lib. I've searched all files in solution directory mentioning tbb_debug.lib as a substring, but the only matches was in generated .obj and .lib files - not in any source or project files. Where is the magic?
This question is not only related to OpenCV, but to whole process of working with .lib-files.
Update
There was a #pragma comment(lib, "tbb_debug.lib")
directive in TBB include file _tbb_windef.h, so now I can understand from where did it go.
What I still don't understand is why it is not statically linked in opencv_core231d.lib? I've set Librarian -> Link Library Dependencies option to Yes. And there are no #pragma comment(lib, "tbb_debug.lib")
directives in my project - I've checked preprocessor output.
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您所包含的头文件之一中可能有一个
#pragma comment(lib, "tbb_debug")
。这与使用英特尔的线程构建块有关。请参阅此博客文章了解更多信息:http://software.intel.com/en-us/blogs/2008/07/07/get-tbb-going-by-a-single-click/
There's probably a
#pragma comment(lib, "tbb_debug")
somewhere in one of the header files you are including.This is to do with using the thread building blocks by Intel. See this blog post for more information: http://software.intel.com/en-us/blogs/2008/07/07/get-tbb-going-by-a-single-click/