I found the following solution:
If we use delayed DLL loading then we get a chance to set the DLL search path before the program attempts to load the DLLs.
To do this, the following needed to be added to the linker options: /DELAYLOAD:libmx.dll /DELAYLOAD:libeng.dll
and it's necessary to link against delayimp.lib
. After doing this, we can add a call to SetDllDirectory() with the path to the location of the libmx.dll and libeng.dll to the beginning of the main/WinMain function.