与MSVC中的静态和动态库链接 [英] Linking with both static and dynamic libraries in MSVC

查看:245
本文介绍了与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.

这篇关于与MSVC中的静态和动态库链接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆