Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
mbuild vs. mex pre-compiling in MATLAB Compiler projects

Subject: mbuild vs. mex pre-compiling in MATLAB Compiler projects

From: Matt J

Date: 8 Jul, 2014 08:54:10

Message: 1 of 1

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,

  Deployment\deployment\linterpcpp.cpp(140) : error C2664: 'mxCreateNumericArray_730' : cannot convert parameter 2 from 'int [2]' 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.

Any ideas what's happening?

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us