MATLAB: Use compiled Mex file from a different machine

mex compiler

I am using the compiled Mex files provided by my team member. I can call the API without any problem. However, if I call the same API twice, with the exact same input, I get different output with some random noise added.
My team member who compiled the C code runs the same thing on his computer, and he does not see the problem. Do I have to compile the C to Mex it on my own machine?
Thanks

Best Answer

The most probable cause for an error like you describe is that there is a pointer dereference to memory that does not belong to the variables nominally being accessed. Those kinds of errors can result in the program appearing to work for someone but crashing badly for someone else running exactly the same binary, who happens to call it at a different life-cycle of their own code where the other variables are laid out differently, tickling a crash.
Compiling the code on your own machine typically makes little to no difference for problems such as these -- unless, that is, you happen to have a compiler environment that does a better job of detecting bad pointers.