Matlab mex "Missing dependent shared libraries"

Viewed 4007

I have a couple mex files I'm creating in Matlab 2017a. When I compile them with Visual Studio C++ 2017, they run fine on my computer. However, when I attempt to use them on another computer, I get an error that says

Error using mfss_mex.filter_uni
Invalid MEX-file  
'path_to_mex_file\mexfile.mexw64':
Missing dependent shared libraries:
'MSVCP140.dll' required by
'path_to_mex_file\mexfile.mexw64'
'VCRUNTIME140.dll' required by
'path_to_mex_file\mexfile.mexw64'

I think I could resolve this by installing the Visual Studio runtime on every computer this will get run on but I'd like to avoid that. Is there a way to compile these mex files and avoid these dependencies with the Visual Studio C++ compiler?

2 Answers

I had the same problem. I solved it by re-mex the original .c file in MATLAB; If you have the original .c file, the simple way is:

mex -setup
mex NAME.c

(Here NAME represents the name of your invalid .mexw64 file) In this case, for example:

mex mexfile.c
Related