为什么 Visual Studio 找不到我的 DLL?

Why can#39;t Visual Studio find my DLL?(为什么 Visual Studio 找不到我的 DLL?)
本文介绍了为什么 Visual Studio 找不到我的 DLL?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

问题描述

在 Visual Studio 2010 中,在 VC++ 目录下 >可执行目录,我已经指定了glew32d.dll的路径.但是,当我运行可执行文件时,它仍然抱怨.

In Visual Studio 2010, under VC++ Directories > Executable Directories, I have specified the path to glew32d.dll. However, when I run the executable, it still complains.

另一方面,如果我将 DLL 复制到本地文件夹并运行可执行文件,则它不会抱怨.

On the other hand, if I copy the DLL into the local folder and run the executable then, it doesn't complain.

谁能告诉我如何解决这个问题?另外,为什么 Visual Studio 无法识别该路径?

Can someone please tell me how to fix this? Also, why is Visual Studio not recognizing that path?

更新场景:我目前使用一个模板项目,我将其用作许多项目的入门代码.该模板依赖于glew32d.dll.我通常将所有依赖的 dll 存储在一个公共 bin 文件夹中.我希望引用这个文件夹,Visual Studio 可以从那里读取 dll,而不必每次都复制 dll.处理这个问题的好方法是什么?

Update Scenario: I currently use a template project which I use as a starter code for a lot of my projects. This template depends on glew32d.dll. I usually store all dependent dlls in a common bin folder. I was hoping to reference this folder and Visual studio could read the dlls from there, instead of me having to copy the dlls everytime. What would be a good way to handle this?

推荐答案

在项目设置中指定 DLL 文件的路径并不能确保您的应用程序在运行时找到 DLL.您只告诉 Visual Studio 如何找到它需要的文件.这与程序如何在构建后找到它需要的东西无关.

Specifying the path to the DLL file in your project's settings does not ensure that your application will find the DLL at run-time. You only told Visual Studio how to find the files it needs. That has nothing to do with how the program finds what it needs, once built.

将 DLL 文件与可执行文件放在同一文件夹中是迄今为止最简单的解决方案.这是依赖项的默认搜索路径,因此您无需如果你走那条路,做任何特别的事情.
为避免每次都手动执行此操作,您可以为您的项目创建一个构建后事件,该事件会在构建完成后自动将 DLL 复制到适当的目录中.

Placing the DLL file into the same folder as the executable is by far the simplest solution. That's the default search path for dependencies, so you won't need to do anything special if you go that route.
To avoid having to do this manually each time, you can create a Post-Build Event for your project that will automatically copy the DLL into the appropriate directory after a build completes.

或者,您可以将 DLL 部署到 Windows 并排缓存,并将清单添加到您的应用程序中,指定位置.

Alternatively, you could deploy the DLL to the Windows side-by-side cache, and add a manifest to your application that specifies the location.

这篇关于为什么 Visual Studio 找不到我的 DLL?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

相关文档推荐

How do compilers treat variable length arrays(编译器如何处理变长数组)
Deduce template argument from std::function call signature(从 std::function 调用签名推导出模板参数)
check if member exists using enable_if(使用 enable_if 检查成员是否存在)
Standard Library Containers with additional optional template parameters?(具有附加可选模板参数的标准库容器?)
Uses of a C++ Arithmetic Promotion Header(C++ 算术提升标头的使用)
Parameter pack must be at the end of the parameter list... When and why?(参数包必须位于参数列表的末尾...何时以及为什么?)