Strange MEX Compile Issue
7 views (last 30 days)
Show older comments
I am currently using MATLAB 2019a (Research Licence) and am writing some MEX utility functions.
I have finished a couple of scripts today which compiled this morning, and I have used them a handful of times since. I started to work on another script for myself and am getting an unusual error when I attempt to compile:
>> mex sum_3D.c
Building with 'MinGW64 Compiler (C)'.
Error using mex
C:\Work\MY_Utilities\sum_3D.c:12:6: error: conflicting types for 'mexFunction'
void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
^~~~~~~~~~~
In file included from C:\Work\MY_Utilities\sum_3D.c:1:0:
C:\Program Files\MATLAB\R2019a/extern/include/mex.h:356:6: note: previous declaration of 'mexFunction' was here
void mexFunction(
I'm storing all my working data, etc. in
'C:\Work\'
and I have write permissions to it. I've stripped all the code I was writing out of the sum_3D.c file so tha now it just loks like this:
// Sum tissue values over each slice of a 3D matrix
#include <mex.h>
#include <matrix.h>
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
void exit_now(char *err_text)
{
mexErrMsgTxt(err_text);
}
void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
{
exit_now("\nTest.\n");
}
Confusingly, the code I used this morning which is kept in the same folder and has the exact same declarations/header files/mexFunction arguments etc. recompiles successfully! I've closed down MATLAB multiple times and done a cold boot and it has not solved the problem (which, lets be honest, it usually does). Does anybody know what could be causing this?
Thanks in advance.
2 Comments
Geoff Hayes
on 28 Feb 2020
Rowan - if you open the file C:\Program Files\MATLAB\R2019a/extern/include/mex.h, what is the signature for mexFunction? Is it identical to
void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
?
Answers (0)
See Also
Categories
Find more on Write C Functions Callable from MATLAB (MEX Files) in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!