MATLAB: Call a mex file and using coder

code generationmatlab codermex

I have some legacy Matlab code which makes a call to a mex file, call it get_score. The mex file was written in C. This Matlab code was then compiled to C using the mcc command. This was all done on an older version of Matlab.
We are now upgrading to the latest version of Matlab so I will be using Matlab Coder to generate C code from our Matlab code. What is the correct way to call the get_score mex file? I tried running mex on the c code and generating a new mexw32 file and calling that but when I attempt to run coder I get the error Unsupported file extension 'mexw32'.
Is the proper way to do this just compile the C code to a standard dll using, say Visual Studio, and then call the dll using coder.ceval?

Best Answer

The thing about mex files is they require MATLAB to run (MATLAB executable). MATLAB coder can generate more generic c-code that can be utilized independent of MATLAB so if you try to call a mex-file from this code you may run into issues.
It sounds like you already know what to do and you can use the ceval command directly on the C-code that the mex file utilizes.
Related Question