Dependent dll library

Libtorch is used for inference under C++, and both Release and Debug must be supported at the same time, but I found that the dlls that depend on the two modes have the same name. When I add the directory of the dependent library to the environment variable, the exe cannot distinguish between Release and Debug when looking for the dependent dll, which causes the program to crash. How can I solve it? The exe cannot be placed in the same directory as the dependent dll, it is best if it can be assigned to a fixed directory.