How do I run the "UComp" library as a MEX file without causing MATLAB to crash?

1 view (last 30 days)
I am trying to use "UComp", a C++ library for statistical modelling, within MATLAB 2022a by compiling it as a MEX file.  More info about "UComp" can be found here:
https://github.com/djpedregal/UComp
The MEX file builds successfully, but MATLAB crashes whenever I call the MEX file.
How do I use the "UComp" library without crashing MATLAB?

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 26 May 2023
The MEX file for the "UComp" is not intended to be run directly in MATLAB, and doing so will likely create a segmentation violation and cause the whole MATLAB process to crash.
In this case, you should use the wrappers provided by the "UComp" library. Instead of calling the "UComp" function (which calls the MEX file directly), you should add the folder containing the "UComp" function's MATLAB wrapper (likely called something like "UCompMATLAB2.2.2/") to the MATLAB path. You can then call the "UC" function in MATLAB using the "UC.m" file instead.

More Answers (0)

Categories

Find more on Write C Functions Callable from MATLAB (MEX Files) in Help Center and File Exchange

Products


Release

R2022a

Community Treasure Hunt

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

Start Hunting!