简体   繁体   English

如何告诉 Visual Studio 我的其他 .dll 文件在哪里?

[英]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这是它目前的样子
dll

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我希望我已经涵盖了一个好的答案所需的重要信息,如果没有,请让我知道我还应该添加什么

  • Microsoft Visual Studio 2019微软 Visual Studio 2019
  • Currently running 64-bit platform with Debug configuration.当前运行具有调试配置的 64 位平台。 Hence the -d suffix因此-d后缀

You could create a path environment for your specified directory, which is like drescherjm's suggestion.您可以为您指定的目录创建一个路径环境,这就像 drescherjm 的建议。 The steps:步骤:

  1. Right-click “This PC” -> “Properties”-> “Advance System settings”右键“此电脑”->“属性”->“高级系统设置”
  2. Click “Environment Variables”点击“环境变量”
  3. In the System Variables group, edit “Path”在系统变量组中,编辑“路径”
  4. Add your directory, for example: ”D:\\ SFML-2.5.1\\bin”添加您的目录,例如:“D:\\SFML-2.5.1\\bin”
  5. Restart your visual studio and re-open your project重新启动您的视觉工作室并重新打开您的项目

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.

相关问题 在Visual Studio '13中,我该怎么做,以便可以在exe的相对子文件夹中包含dll文件? - In visual studio '13 how do I make it so I can include dll files in a relative sub folder of my exe? 包含文件时,如何告诉Visual Studio使用项目目录而不是当前文件目录? - How can I tell Visual Studio to use the project directory instead of the current file directory when including files? (Visual Studio)如何知道我的c ++程序中哪些部分已运行,哪些未运行? - (Visual Studio) How can I tell which parts of my c++ program ran and which didn't? 如何让Visual Studio将所需的.dll文件复制到release文件夹中? - How can I make Visual Studio copy the required .dll files into the release folder? 如何使我的应用程序使用Visual Studio查找第三方DLL? - How can I make my application find a third-party DLL using Visual Studio? 在使用 Visual Studio 进行调试时,我的应用程序在外部 DLL 调用上冻结。 我怎样才能找到这个 DLL 的路径? - While debugging with Visual Studio, my application freezes on an external DLL call. How can I find the path to this DLL? 我的Visual Studio项目需要的DLL文件列表 - List of dll files my Visual Studio project needs 如何在Visual Studio中包含dll / lib文件 - How to include files dll/lib files on visual studio 如何告诉 Visual Studio 我的 header 应该是 C++ 而不是 C? - How do I tell Visual Studio that my header should be C++ and not C? 如何从Visual Studio中的项目解决方案中删除其他构建文件 - How to Delete Additional build files from the Project Solution in visual studio
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM