[英]How can I tell Visual studio where my additional .dll files are?
I have recently switched my IDE to Visual Studio 2019 for C++ projects.我最近将我的 IDE 切换到 Visual Studio 2019 用于 C++ 项目。 I easily followed a tutorial into setting up a new library like SFML into visual studio, and tell it where the additional include and library directories are.
我很容易地按照教程在 Visual Studio 中设置了一个像 SFML 这样的新库,并告诉它额外的包含和库目录在哪里。
But there is something else that is required for it to work, which are the .dll
files.但是它的工作还需要其他一些东西,那就是
.dll
文件。 Every page I followed, even the Documentation by the SFML website , it says that they have to be in the same directory as my project.我关注的每个页面,甚至是SFML 网站的文档,都说它们必须与我的项目位于同一目录中。 That means I need to copy-paste the 7-8 files into my project directory.
这意味着我需要将7-8 个文件复制粘贴到我的项目目录中。 This really makes the folder look untidy.
这确实使文件夹看起来不整洁。 I would like to create a new folder and tell Visual Studio where those files are.
我想创建一个新文件夹并告诉 Visual Studio 这些文件在哪里。 I tried going doing this
我试着去做这个
Project -> Properties -> Linker -> Input -> Additional dependencies
Usually, the lines that would work are通常,行得通的线路是
sfml-system-d.lib
sfml-window-d.lib
...
I tried doing $(ProjectDir)valid path\\ sfml-files.lib
but this gives me the linker error, saying that It could not find the file.我试着做
$(ProjectDir)valid path\\ sfml-files.lib
但这给了我链接器错误,说它找不到文件。
If I simply move the .dlls
into a folder without doing anything, the code would compile and link fine.如果我只是将
.dlls
移动到一个文件夹中而不做任何事情,代码将编译和链接正常。 But when it runs, Windows gives me a pop-up box with the same error message.但是当它运行时,Windows 会给我一个带有相同错误消息的弹出框。
Here is how it currently looks这是它目前的样子
Looks really messy, I just want to be able to move them into dependencies
like how src
contains the source files.看起来真的很乱,我只是希望能够将它们移动到
dependencies
例如src
如何包含源文件。
How can I achieve this?我怎样才能做到这一点?
As it is now, it works perfectly fine.就像现在一样,它工作得很好。 The issue only occurs when I try to create a new folder.
仅当我尝试创建新文件夹时才会出现此问题。
I hope I have covered the important information required for a good answer, If not please let me know what more I should add我希望我已经涵盖了一个好的答案所需的重要信息,如果没有,请让我知道我还应该添加什么
-d
suffix-d
后缀You could create a path environment for your specified directory, which is like drescherjm's suggestion.您可以为您指定的目录创建一个路径环境,这就像 drescherjm 的建议。 The steps:
步骤:
The easier solution might be to put them in the x64 subdirectory.更简单的解决方案可能是将它们放在 x64 子目录中。 This allows you to have various builds side by side (x86/x64, debug/release).
这允许您并排进行各种构建(x86/x64,调试/发布)。
Since this x64 directory is where the EXE is located, it is the first directory searched for DLL's.由于此 x64 目录是 EXE 所在的位置,因此它是第一个搜索 DLL 的目录。 It will take precedence over the Path solution suggested in the other answer.
它将优先于其他答案中建议的 Path 解决方案。 The Path directories are searched last of all.
最后搜索 Path 目录。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.