I am seeing different behavior when a mex file is compiled using mbuild (as part of a larger MATLAB compiler project) as compared to when it is compiled individually using mex().
One way to include a mex file in the building of a standalone is to pre-compile it from the command line using the mex command and then to add the mex file manually to the list of dependent files. When I take this approach, mex() completes the compilation without errors and, when I run a project build, everything works fine and the resulting standalone .exe performs as desired.
If however, I replace one of the project's mex files, say linterpcpp.mexw64, with the source code file linterpcpp.cpp that it originates from and try to rebuild, mbuild() will run its own pre-compilation of linterpcpp.cpp as part of the overall process of building the standalone. This leads to to an error as follows,
linterpcpp.cpp <snip> Deployment\deployment\linterpcpp.cpp(140) : error C2664: 'mxCreateNumericArray_730' : cannot convert parameter 2 from 'int ' to 'const mwSize *' Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
Error: An error occurred while shelling out to mbuild (error code = 9). Unable to build executable.
I am confused because the file linterpcpp.cpp compiles fine when I do
>> mex linterpcpp.cpp
and I have only one compiler installed on the machine, Microsoft Software Development Kit (SDK) 7.1, so both mbuild() and mex() have to be using the same compiler C/C++ compiler.