Ok so I'm a step closer to the solution, the problem in my case is libstdc++-6.dll located in matlabroot/bin/win64 (and also in the folder of the external library). When I run the cmd from matlab, the path changes to matlabroot/bin/win64;path, therefore the dll in matlabroot/bin/win64 is used instead of using the one of my library. I try to fix this problem for my particular application, unfortunately renaming the dll before running the external program and reverting the change afterwards is not possible due to access rights. My idea is to remove the matlab dir from the path before running my command. Something like that should do the trick: system(['set path=%path:' matlabroot '\bin\win64;=% & myCall']); Unfortunately this does not work, not sure why. If I try it manually from matlab, it works:
system('cmd') set path=%path:' matlabroot '\bin\win64;=% myCall
But I need to bring these two commands sequentially into one system call. Any ideas? Or is there another way to change the PATH used by system()?