与MSVC中的静态和动态库链接

与MSVC中的静态和动态库链接

问题描述:

我正在研究一个链接到静态库的c ++项目.但是,我想使用英特尔的TBB,它仅作为动态库提供.我试图在Visual Studio中进行设置,但无法正常工作.如果可能的话,没有人有详细的指导吗?

I am working on a c++ project that links to a static library. However, I want to use intel's TBB, which is only available as a dynamic library. I tried to set this up in visual studio but I can't get it to work. Does anyone have detailed directions to do this if it is possible?

通常,当一个库作为动态库(.dll)可用时,它也附带一个.lib文件以进行链接(如本问题).可以将其添加到项目的输入列表中,就像使用静态库一样

Typically when a library is made available as a dynamic library (.dll), it also comes with a .lib file to link against (as discussed in this question). This can be added to the project's list of inputs the same way that a static library is

项目属性->配置属性->链接器->输入->其他依赖关系(在VS2008中)

Project Properties->Configuration Properties->Linker->Input->Additional Dependencies (in VS2008)

如果.lib不可用,则必须在运行时使用Win32 API函数

If a .lib is not available, then you'll have to load the .dll at runtime using Win32 API function LoadLibraryEx and then subsequent calls to GetProcAddress to get the addresses of the functions you need.