Hi, I think I may have found something potentially helpful.
I had a very similar issue, and just resolved it. In case it's relevant, I was using Intel's Fortran compiler in a Visual Studio project to build a fortran file. TLDR; The built EXE was trying to load some dll that it couldn't do from within MATLAB, but within native windows cmd window, or double-click, evidently it could load it.
- You need to change the runtime library setting for your project within Visual Studio - the default within Visual Studio is to produce an executable that requires the Fortran runtime libraries.
- Change to a Release configuration, then rIght click on your project in the solution explorer, select Properties, then in the Configuration Properties > Fortran > Libraries page change the Runtime Library option to "Multithreaded". Rebuild your project.
- (If you use OpenMP within your project, then you will still have a dependency on some of the OpenMP DLL's.)
I sort of backed into this when I tried to run my compiled .exe on another PC that didn't have the same build environment setup, and it barfed on me indicating "libmmdd.dll" was not found. Additionally, I tried system('cmd &') to have Matlab open up a command window..and I found that one compiled version (i.e. via G77) worked, and the one I used Visual Studio for, didn't work!
From there I guess that it couldn't load that library in the MATLAB "system" scaffolding. I am not sure.
Regardless, for me the key was changing the "Runtime Library" option to "Multithreaded", from "Multithreaded dll". As soon as I could do it, the exe was runnable. Note: runnable from within Matlab, as well as runnable on the other Windows PC, that did not have the same development-environment. Seems all dependencies was 'packaged' into the fortran .exe.
Hope this helps someone! :)
Josh
2 Comments
Direct link to this comment
https://in.mathworks.com/matlabcentral/answers/316233-can-t-run-external-program#comment_491982
Direct link to this comment
https://in.mathworks.com/matlabcentral/answers/316233-can-t-run-external-program#comment_491982
Direct link to this comment
https://in.mathworks.com/matlabcentral/answers/316233-can-t-run-external-program#comment_794495
Direct link to this comment
https://in.mathworks.com/matlabcentral/answers/316233-can-t-run-external-program#comment_794495
Sign in to comment.