問題描述
在 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?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!