0

Let's say I have a visual studio project using some external code in A.lib and A.dll.

On Debug and Release configurations, I need to specify different link paths for A.lib such that both are linking the right library.

But how about DLLs? How do I specify them to take higher priority than the PATH system environment variable ?

The point is that I have a python script which uses the PATH env variable to get the release version of the DLL. I just need a way to override this and point to a different path of the DLL in visual studio and DEbug configuration.

paduraru2009
  • 595
  • 2
  • 5
  • 11
  • One technique is to use a Post Build Event to copy associated/related `.lib` and `.dll` files to appropriate directories for Debug vs. Release builds. Example here: https://stackoverflow.com/a/3719097/6610379 – Phil Brubaker Aug 01 '18 at 16:56
  • "On Debug and Release configurations, I need to specify different link paths for A.lib such that both are linking the right library." - is that really necessary? As long as the public interfaces both versions expose are the same, either .lib ought to work. – Rup Aug 02 '18 at 09:16
  • You could also put the .lib paths in an .h file somewhere, with `#ifdef DEBUG` and [`#pragma comment (lib)`](https://learn.microsoft.com/en-gb/cpp/preprocessor/comment-c-cpp) – Rup Aug 02 '18 at 09:18
  • Any update for this issue? Have you resolved this issue? If not, would you please let me know the latest information about this issue? – Leo Liu Aug 07 '18 at 02:19
  • @paduraru2009, What bout this issue in your side? If this issue has been resolved, please mark helpful reply as the answer or share your answer here. If not, feel free to share the latest information. – Jack Zhai Sep 01 '18 at 03:54

1 Answers1

0

For building, you don't need the DLL.

When debugging, look at the per-configuration properties of the project, in particular the top-level Debugging entry.

However, you probably don't need PATH anyway. It's only used as a last resort when finding DLL's. The first directory searched is the application directory, and when debugging that will be the x64\Debug or x64\Release folder.

I'm not sure what your Python script is doing, but it sounds weird that it's looking for DLLs in a way that's totally unlike Windows.

MSalters
  • 173,980
  • 10
  • 155
  • 350