Different outputs for mex library and c library

Hi,
I got into a weird situation with the coder: i have converted a matlab function to a mex function and verified that their outputs match. However, when I use the same code base to generate a static c library that is not the case anymore. Any ideas of how I may go about debugging this. I'd gladly share the files, though I do not not have a minimalistic test case.
-- Octav

2 Comments

Maybe put some printf in your code at specific points. Then compare the printed results from the mex with the one of the library. In this way you can narrow down the problem to a specific area in your code. Afterwards you have to dig into it by using your brain excessively.
As far as I know the mex target generates more or less the same C code as the library target. It only adds a wrapper for converting the data types to mxArrays and back.
The best is to share an example (if too complicated). If its too complicated and long consider contacting MW Technnical Support.
The one difference between the MEX target and DLL target that I can think of is that functions unsupported for code-generation will not generate any code for the DLL target (in the case of a MEX target, it simply dispatches the call to the MATLAB Engine). Examine your code for any functions declared using eml.extrinsic/coder.extrinsic.

Sign in to comment.

Answers (0)

Categories

Find more on MATLAB Coder in Help Center and File Exchange

Products

Asked:

on 14 Aug 2012

Community Treasure Hunt

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

Start Hunting!