如何在Visual Studio中设置路径?

时间:2021-11-18 22:44:20

How do I set a path for DLL files to be searched in Visual Studio for a particular project alone?

如何为一个单独的项目在Visual Studio中为DLL文件设置路径?

Now I am setting it in the environment path variable, but I would like better control over this.

现在我将它设置在环境路径变量中,但是我希望更好地控制它。

4 个解决方案

#1


41  

You have a couple of options:

你有几个选择:

  • You can add the path to the DLLs to the Executable files settings under Tools > Options > Projects and Solutions > VC++ Directories (but only for building, for executing or debugging here)
  • 您可以将DLLs的路径添加到工具>选项>项目和解决方案> vc++目录下的可执行文件设置(但仅用于构建、执行或调试)
  • You can add them in your global PATH environment variable
  • 您可以将它们添加到全局路径环境变量中。
  • You can start Visual Studio using a batch file as I described here and manipulate the path in that one
  • 您可以使用一个批处理文件开始Visual Studio,就像我在这里描述的那样,并对其中的路径进行操作。
  • You can copy the DLLs into the executable file's directory :-)
  • 您可以将dll复制到可执行文件的目录:-)

#2


89  

Search MSDN for "How to: Set Environment Variables for Projects". (It's Project>Properties>Configuration Properties>Debugging "Environment" and "Merge Environment" properties for those who are in a rush.)

搜索MSDN“如何:为项目设置环境变量”。(这是>项目>配置的>调试“环境”和“合并环境”的属性,为那些正在忙碌的人。)

The syntax is NAME=VALUE and macros can be used (for example, $(OutDir)).

语法是名称=值,可以使用宏(例如$(OutDir))。

For example, to prepend C:\Windows\Temp to the PATH:

例如,预先考虑C:\Windows\Temp路径:

PATH=C:\WINDOWS\Temp;%PATH%

Similarly, to append $(TargetDir)\DLLS to the PATH:

同样,要追加$(TargetDir)\DLLS到路径:

PATH=%PATH%;$(TargetDir)\DLLS

#3


8  

If you only need to add one path per configuration (debug/release), you could set the debug command working directory:

如果您只需要为每个配置添加一个路径(调试/发布),那么您可以设置调试命令工作目录:

Project | Properties | Select Configuration | Configuration Properties | Debugging | Working directory

项目|属性|选择配置|配置属性|调试|工作目录。

Repeat for each project configuration.

对每个项目配置重复。

#4


1  

Set the PATH variable, like you're doing. If you're running the program from the IDE, you can modify environment variables by adjusting the Debugging options in the project properties.

设置PATH变量,就像你在做的一样。如果您是从IDE运行程序,您可以通过调整项目属性中的调试选项来修改环境变量。

If the DLLs are named such that you don't need different paths for the different configuration types, you can add the path to the system PATH variable or to Visual Studio's global one in Tools | Options.

如果DLLs被命名为这样,您不需要不同的配置类型的不同路径,您可以添加路径到系统路径变量或Visual Studio的global one在工具|选项中。

#1


41  

You have a couple of options:

你有几个选择:

  • You can add the path to the DLLs to the Executable files settings under Tools > Options > Projects and Solutions > VC++ Directories (but only for building, for executing or debugging here)
  • 您可以将DLLs的路径添加到工具>选项>项目和解决方案> vc++目录下的可执行文件设置(但仅用于构建、执行或调试)
  • You can add them in your global PATH environment variable
  • 您可以将它们添加到全局路径环境变量中。
  • You can start Visual Studio using a batch file as I described here and manipulate the path in that one
  • 您可以使用一个批处理文件开始Visual Studio,就像我在这里描述的那样,并对其中的路径进行操作。
  • You can copy the DLLs into the executable file's directory :-)
  • 您可以将dll复制到可执行文件的目录:-)

#2


89  

Search MSDN for "How to: Set Environment Variables for Projects". (It's Project>Properties>Configuration Properties>Debugging "Environment" and "Merge Environment" properties for those who are in a rush.)

搜索MSDN“如何:为项目设置环境变量”。(这是>项目>配置的>调试“环境”和“合并环境”的属性,为那些正在忙碌的人。)

The syntax is NAME=VALUE and macros can be used (for example, $(OutDir)).

语法是名称=值,可以使用宏(例如$(OutDir))。

For example, to prepend C:\Windows\Temp to the PATH:

例如,预先考虑C:\Windows\Temp路径:

PATH=C:\WINDOWS\Temp;%PATH%

Similarly, to append $(TargetDir)\DLLS to the PATH:

同样,要追加$(TargetDir)\DLLS到路径:

PATH=%PATH%;$(TargetDir)\DLLS

#3


8  

If you only need to add one path per configuration (debug/release), you could set the debug command working directory:

如果您只需要为每个配置添加一个路径(调试/发布),那么您可以设置调试命令工作目录:

Project | Properties | Select Configuration | Configuration Properties | Debugging | Working directory

项目|属性|选择配置|配置属性|调试|工作目录。

Repeat for each project configuration.

对每个项目配置重复。

#4


1  

Set the PATH variable, like you're doing. If you're running the program from the IDE, you can modify environment variables by adjusting the Debugging options in the project properties.

设置PATH变量,就像你在做的一样。如果您是从IDE运行程序,您可以通过调整项目属性中的调试选项来修改环境变量。

If the DLLs are named such that you don't need different paths for the different configuration types, you can add the path to the system PATH variable or to Visual Studio's global one in Tools | Options.

如果DLLs被命名为这样,您不需要不同的配置类型的不同路径,您可以添加路径到系统路径变量或Visual Studio的global one在工具|选项中。