Cannot create mex file even though compiler installed and recognized

1 Ansicht (letzte 30 Tage)
Emil Partsch
Emil Partsch am 24 Sep. 2018
Bearbeitet: Emil Partsch am 25 Sep. 2018
I am trying to compile some mex files. Since I got an error, I tried the standard matlab test https://se.mathworks.com/help/matlab/matlab_external/build-an-executable-mex-file.html:
copyfile(fullfile(matlabroot,'extern','examples','refbook','timestwo.c'),'.','f')
mex timestwo.c
I get the following error:
Building with 'Xcode with Clang'.
Error using mex
'/path/timestwo.mexmaci64' is not a MEX file. For more information, see File is not a MEX file.
Error in mextest (line 2)
mex timestwo.c
Note that the path is correct and that the file is indeed there. I am not sure what could be wrong. I run the newest version of matlab and xcode on mac and my OS is High Sierra, version 10.13.6
Any help is highly appreciated :-)
Thanks in advance
  8 Kommentare
OCDER
OCDER am 24 Sep. 2018
Can you show us the timestwo.c code? Or are you able to compile another mex code from the matlab examples?
Emil Partsch
Emil Partsch am 25 Sep. 2018
Bearbeitet: Emil Partsch am 25 Sep. 2018
I am able to compile other mex codes, but matlab won't recognize any mex compiled files.
Here is the timestwo.c code:
#include "mex.h"
/*
* timestwo.c - example found in API guide
*
* Computational function that takes a scalar and doubles it.
*
* This is a MEX-file for MATLAB.
* Copyright 1984-2011 The MathWorks, Inc.
*/
void timestwo(double y[], double x[])
{
y[0] = 2.0*x[0];
}
void mexFunction( int nlhs, mxArray *plhs[],
int nrhs, const mxArray *prhs[] )
{
double *x,*y;
size_t mrows,ncols;
/* Check for proper number of arguments. */
if(nrhs!=1) {
mexErrMsgIdAndTxt( "MATLAB:timestwo:invalidNumInputs",
"One input required.");
} else if(nlhs>1) {
mexErrMsgIdAndTxt( "MATLAB:timestwo:maxlhs",
"Too many output arguments.");
}
/* The input must be a noncomplex scalar double.*/
mrows = mxGetM(prhs[0]);
ncols = mxGetN(prhs[0]);
if( !mxIsDouble(prhs[0]) || mxIsComplex(prhs[0]) ||
!(mrows==1 && ncols==1) ) {
mexErrMsgIdAndTxt( "MATLAB:timestwo:inputNotRealScalarDouble",
"Input must be a noncomplex scalar double.");
}
/* Create matrix for the return argument. */
plhs[0] = mxCreateDoubleMatrix((mwSize)mrows, (mwSize)ncols, mxREAL);
/* Assign pointers to each input and output. */
x = mxGetPr(prhs[0]);
y = mxGetPr(plhs[0]);
/* Call the timestwo subroutine. */
timestwo(y,x);
}

Melden Sie sich an, um zu kommentieren.

Antworten (0)

Kategorien

Mehr zu C Matrix API finden Sie in Help Center und File Exchange

Produkte


Version

R2018a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by