Matlab mex “Missing dependent shared libraries”

本秂侑毒 提交于 2019-12-12 15:31:47

问题


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?


回答1:


The Mathworks solution to this is to install the C++ compiler runtime on any computer that has this issue.

I found that I simply needed to copy the offending .dll files (MSVCP140.dll and VCRUNTIME140.dll) into the same folder with my .mexw64 files and everything ran without a problem.




回答2:


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


来源:https://stackoverflow.com/questions/44315942/matlab-mex-missing-dependent-shared-libraries

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!