0

Recently, I try to build my code on windows using Clang on visual studio 2019.
But I found that my exe file cannot load the dll file, when dll locates at a different folder.

Say, file path as:

bin: root/bin/test.exe
lib: root/lib/testlib.dll, testlib.lib.

I can solve it by setting the INSTALL RPATH at the CMakeList.txt for ubuntu.
But for windows, would you mind telling me how I can specify the dll load path for a specific executable at runtime?

Mangoccc
  • 41
  • 7
  • Thank you! But I may prefer NOT to hardcode my source file, such as changing the current work directory or add the dll directory. I am wondering if the visual studio can add a search path for the one specific exe when build it. – Mangoccc Jun 27 '21 at 09:37
  • "I am wondering if the visual studio can add a search path for the one specific exe when build it." - The referenced question tells that It is **Windows** who doesn't understand RPATH settings in the executable/library. How do you expect Visual Studio to add RPATH information into the executable, if that information cannot be used when Windows runs an executable? – Tsyvarev Jun 27 '21 at 10:21
  • Note, that you may configure Visual Studio to modify environment (e.g. `PATH` variable) when it runs your executable. That is, the executable could be successfully run from Visual Studio, but running it e.g. from the terminal will still require manual settings in the environment. See e.g. [that question](https://stackoverflow.com/questions/1005901/how-to-set-path-environment-variable-using-cmake-and-visual-studio-to-run-test) about environment settings in Visual Studio via CMake. – Tsyvarev Jun 27 '21 at 10:29

0 Answers0