0

I use LoadLibrary to dynamically load a library in my application. In Visual Studio, I can set different build configurations: x86 or x64 / Debug or Release. I can also build a library from source in different configurations but how to implement loading library in my application which chooses appropriate target based on build configuration which is set in Visual Studio, for example: when I build x64-Release application LoadLibrary should also load x64-Release library.

6
  • Give the DLLs different names eg my_dll_x64_debug.dll, my_dll_x64_release.dll etc. Or if you have many DLLs for each ABI use folders named for the ABI and put the corresponding set of DLLs in each folder. Commented Jun 23, 2023 at 8:06
  • But how at runtime choose an appropriate library ? It looks like I need some condition to set a path for LoadLibrary. Commented Jun 23, 2023 at 8:17
  • 2
    Use the Predefined macros to detect the built ABI. eg _WIN32 and _WIN64 ... Commented Jun 23, 2023 at 8:20
  • 2
    @Irbis - The program has to know what you did at build time - to add a suffix to the library name and/or look in a specific directory. There are macros defined for that, like _DEBUG and _WIN64 Commented Jun 23, 2023 at 8:21
  • Not a general solution but in some few scenarios it can be applicable to simply place the right dll into the same directory as the executable – all dlls then with equal names or you look up the dll by the common prefix only. Commented Jun 23, 2023 at 8:28

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.