Why can#39;t Visual Studio find my 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?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:为什么 Visual Studio 找不到我的 DLL?


基础教程推荐
- 如何通过C程序打开命令提示符Cmd 2022-12-09
- 静态库、静态链接动态库和动态链接动态库的 .lib 文件里面是什么? 2021-01-01
- 如何将 std::pair 的排序 std::list 转换为 std::map 2022-01-01
- 如何在 C++ 中初始化静态常量成员? 2022-01-01
- 常量变量在标题中不起作用 2021-01-01
- 这个宏可以转换成函数吗? 2022-01-01
- 我有静态或动态 boost 库吗? 2021-01-01
- 如何检查GTK+3.0中的小部件类型? 2022-11-30
- 在 C++ 中计算滚动/移动平均值 2021-01-01
- C++结构和函数声明。为什么它不能编译? 2022-11-07