将我的DLL添加到C ++中的Visual Studio项目中 [英] Adding my DLL into a Visual Studio project in C++

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

问题描述

我正在从事一个涉及制作动态链接库的项目,因此我想在Visual Studio的控制台应用程序中对其进行测试。

I am working on a project that involves making a dynamic link library, so I want to test it in a console app in Visual Studio.

DLL也它是在Visual Studio中制作的,功能不多,只有几个功能。我不确定是否只应该在 Properties include 目录面板中包括库标题,还是做其他事情

The DLL is also made in Visual Studio, it doesn't have much, just a few functions in it. I'm not sure if I'm just supposed to include the librarys header in the include directories panel in Properties, or do something else

很多人说我应该在Library或Reference目录中添加其对应的 .lib 文件,但是我不确定VS随DLL一起生成 .lib 文件。我正在使用VS 2015。

A lot of people say I'm supposed to add its corresponding .lib file in the Library or Reference directory, but I'm not sure that VS generates a .lib file alongside the DLL. I'm using VS 2015.

推荐答案

此刻我面前没有VS,但是这些应该是设置它的一般步骤:

I don't have VS in front of me this very moment, but these should be the general steps to set it up:

Properties->Linker->Input: your.lib
Properties->Linker->Additional Library Directories: ../your/bin
Properties->General->Compiler->Additional Include Directories: ../your/include

要构建您的应用,DLL的API标头必须包含在编译时的include中,它是bin中的LIB文件。链接时间。有了应用程序EXE后,所有需要的就是DLL在执行时与EXE放在同一文件夹中。

To build your app, the DLL's API headers must be in the include for the compile-time, it's LIB files in the bin for the link-time. Once you have your app EXE, all you need is the DLL to be in the same folder as your EXE when it executes.

您可能还想添加dll项目并将应用程序项目转换为VS中的通用解决方案,然后从应用程序向dll添加(右键单击)项目依赖项。假设您完全要构建dll,这将确保正确的构建顺序。

You might also want to add the dll project and the app project into a common solution in VS and add (right click) Project Dependency from the app to the dll. This ensures correct order of building, assuming you are going to build the dll at all.

这篇关于将我的DLL添加到C ++中的Visual Studio项目中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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