Clear Filters
Clear Filters

Mex-function crashes under Windows, but runs fine under Mac and Linux

2 views (last 30 days)
Hello,
I’m encountering some issues when running some of my C-mex code on Windows 10 (MATLAB 2019a with Intel Parallel Studio 2019 and MS VS 2017).
I have been using the exact same c-file for quite some time both on my Macs (with XCode/Clang, various recent MATLAB versions) and Linux (with gcc, various MATLAB versions) without any issues, i.e., everything compiles and executes correctly on these systems. Compiling on the Windows machine seems to work fine, too.
mex('-R2018a', 'file_new.c') results in “Building with 'Intel Parallel Studio XE 2019 with Microsoft Visual Studio 2017 (C)'.MEX completed successfully.”
When I execute the compiled mex-file, MATLAB crashes, however. The -R2018a flag does not seem crucial and I rewrote the code such that it's not needed, but MATLAB still crashes. I am able to compile and run a slightly simpler/older version of my C-code on the Windows machine using the same compiler-command as above: mex('-R2018a', 'file_old.c').
I wouldn’t call myself an expert C programmer and I don’t have much experience with running MATLAB on Windows. Given that I'm able to run the old file, but not the new one, I guess it’s more of an issue with my code rather than the Windows system itself. file_new.c uses the same libraries, has a very similar structure and uses very similar commands as file_old.c The only conceptual difference that I can think of is that in file_new.c I’m using mxGetDoubles whereas in the old file I’ve used mxGetPr.
Are there any code pieces that would work fine under Mac/Linux but cause issues under Windows? Any thoughts or advice would be geatly appreciated. Thank you!
Stefan

Accepted Answer

Stefan Weiergraeber
Stefan Weiergraeber on 15 Sep 2020
Just in case sombody else is running into similar issues: After having upgraded the Windows system to MATLAB 2020a and Intel Parallel Studio 2020 with MS VS 2019 my original code compiles and runs as expected. I don't know where exactly the issue was, but the upgrade completely solved the problem.

More Answers (0)

Categories

Find more on MATLAB Compiler in Help Center and File Exchange

Tags

Products


Release

R2019a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!