DLL参考在Visual C ++ [英] DLL References in Visual C++

查看:93
本文介绍了DLL参考在Visual C ++的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有过C ++的经验,但没有MSVC。

I have had C++ experience but not MSVC.

我想做的是将一个开源项目的.dll文件合并到我的项目中。代码是可用的,我已经构建它。我有.dll以及.lib,因为我理解它是C ++项目所必需的。

What I am trying to do is incorporate a .dll from an open source project into my project. The code is available and I have built it. I have the .dll as well as the .lib which as I understand it is required for C++ projects.

现在不幸的是没有简单的添加引用 .dll放入include目录并将其添加到我的解决方案中。我编辑了项目属性页,C / C ++附加包含目录选项以及添加.lib作为附加链接器依赖。我已经为我的解决方案树中的dll和lib创建了一个包含目录。

Now unfortunately there is no simple "Add Reference", drop my .dll into an include directory and add that to my solution. I have edited the project property pages, the C/C++ Additional Include Directories option as well as adding the .lib as an additional linker dependency. I have created an include directory for the dll and lib inside my solution tree.

我的问题是当我尝试包含头文件从文档,VS输出吐出错误消息。现在我意识到,我使用的dll / lib组合和.H文件不存在于我的解决方案,如何添加适当的包括?我使用QT工具包也是工作,但我如何添加其他标题/ dll从开源库不包括我。

My problem is when I try to include the header files from the documentation, VS output spits out error messages. Now I realize that I am using the dll/lib combo and that the .h files are not present in my solution so how do I add the proper includes? I am using QT toolkit also which is working but how I add the other header / dll from the open source library eludes me.

有人可以指出正确的方向。

Can someone please point me in the right direction.

推荐答案

你需要做几件事才能使用这个库:

You need to do a couple of things to use the library:


  1. 确保你有* .lib和* .dll从您要使用的库。如果您没有* .lib,请跳过#2

  1. Make sure that you have both the *.lib and the *.dll from the library you want to use. If you don't have the *.lib, skip #2

在项目中引用* .lib。在解决方案资源管理器中右键单击项目名称,然后选择配置属性 - >链接器 - >输入,并将其名称放在附加依赖关系属性中。

Put a reference to the *.lib in the project. Right click the project name in the Solution Explorer and then select Configuration Properties->Linker->Input and put the name of the lib in the Additional Dependencies property.

你必须确保VS可以找到你刚刚添加的lib,所以你必须去工具菜单,选择选项...然后在项目和解决方案选择VC ++目录。从这里,您可以通过选择显示目录为:下拉框中的库文件设置包含新的库的目录。只需在目录列表中添加您的lib文件的路径。如果你没有lib,你可以省略这个,但是在这里你还需要设置包含你的头文件的目录,以及在包括文件。

You have to make sure that VS can find the lib you just added so you have to go to the Tools menu and select Options... Then under Projects and Solutions select VC++ Directories. From within here you can set the directory that contains your new lib by selecting the 'Library Files' in the 'Show Directories For:' drop down box. Just add the path to your lib file in the list of directories. If you dont have a lib you can omit this, but while your here you will also need to set the directory which contains your header files as well under the 'Include Files'. Do it the same way you added the lib.

完成后,您应该可以使用图书馆。如果你没有一个lib文件,你仍然可以使用dll通过自己导入。在应用程序启动期间,您可以通过调用LoadLibrary显式加载dll(请参阅: http://msdn.microsoft.com/en-us/library/ms684175(VS.85).aspx 了解详情)

After doing this you should be good to go and can use your library. If you dont have a lib file you can still use the dll by importing it yourself. During your applications startup you can explicitly load the dll by calling LoadLibrary (see: http://msdn.microsoft.com/en-us/library/ms684175(VS.85).aspx for more info)

干杯!

EDIT

请务必使用#include< Foo.h>而不是#includefoo.h。前者搜索包含路径。后者使用本地项目文件。

Remember to use #include < Foo.h > as opposed to #include "foo.h". The former searches the include path. The latter uses the local project files.

这篇关于DLL参考在Visual C ++的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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