Compilers can cause unexpected behavior when compiling and executing MEX files. Refer to the following link for a list of supported compiler versions for your MATLAB version:
Switching to a supported compiler version may resolve the issue that you are facing. I would highly suggest taking this step before attempting further troubleshooting.
If the information mentioned above doesn’t solve the issue, altering some of your environment variable settings might do.
You may want to look at the following page for a detailed explanation on the build process,
but to test whether things work on your platform as expected, please follow the procedure mentioned below:
- ‘mex’ compiler setup: In order to setup the mex compiler, just execute the following at your MATLAB command window:
- Use ‘mex’ to build the engine application: In order to build the engine application, use mex as follows:
>> mex -v -client engine <file_name>.c
In the above command, you will see verbose compiler/linker options used to build the application and customize according to your need.
If the information mentioned above doesn’t solve the issue, please follow the procedure mentioned below for further assistance:
- This error might occur because of the options file which gets carried over to a newer release. To fix this issue, you can follow the following steps:
Delete the options file named "mex_C++_maci64.xml" from the Preferences Directory "prefdir".
You can know the "prefdir" for any release using the MATLAB by executing the following command.
MEX, starting 15a, does not require “-setup”. Mex will find a compiler for you and compile the C/C++ file.
>> mex -v -client engine <file_name>.cpp
- If the above step does not resolve the issue, then the issue can be related to some missing libraries. The error in this case might be due to not selecting the engine client, a faulty options file or faulty processing of the options file. In this case, one workaround could be to explicitly specify the libraries while compiling using MEX function. For instance,
>> mex -v -client engine <file_name>.cpp -lMatlabDataArray –lMatlabEngine
I hope the above information helps you.