MEX link failed
    3 visualizaciones (últimos 30 días)
  
       Mostrar comentarios más antiguos
    
I met link failed problem when I compiling mex code. I'm using matlab r2011a, with win7, and I got the same result under linux.
Error Message:
D:\Study Stuff\Robust PCA\Robust PCA\src\ENV\packages\PROPACK>mex reorth_mex.c
    Writing library for reorth_mex.mexw32
    *c:\users\lofi\appdata\local\temp\mex_ufvcxe\reorth_mex.obj .text: undefined reference to '_reorth_'*
    D:\PROGRA~1\MATLAB\R2011A\BIN\MEX.PL: Error: Link of 'reorth_mex.mexw32' 
  failed.
Source Code:
#include <string.h>
#include "mex.h"
/* Template for reorth: */
void reorth_(int *n, int *k, double *V, int *ldv, double *vnew,
      double *normvnew, double *index, double *alpha, double *work,
      int *iflag, int *nre);
/* Here comes the gateway function to be called by Matlab: */
void mexFunction(int nlhs, mxArray *plhs[], 
     int nrhs, const mxArray *prhs[])
{
  int n, k1, k, imethod, inre;
  double *work;
    if (nrhs != 6)
       mexErrMsgTxt("reorth requires 6 input arguments");
    else if  (nlhs < 2)
       mexErrMsgTxt("reorth requires at least 2 output arguments");
    n = mxGetM(prhs[0]); /* get the dimensions of the input */
    k1 = mxGetN(prhs[0]);
    k = mxGetM(prhs[3]) * mxGetN(prhs[3]);
    /* Create/allocate return argument, a 1x1 real-valued Matrix */
    plhs[0]=mxCreateDoubleMatrix(n,1,mxREAL); 
    plhs[1]=mxCreateDoubleMatrix(1,1,mxREAL); 
    if (nlhs>2) 
      plhs[2]=mxCreateDoubleMatrix(1,1,mxREAL); 
    work = mxCalloc(k,sizeof(double));
    memcpy(mxGetPr(plhs[0]),mxGetPr(prhs[1]), n*sizeof(double));
    memcpy(mxGetPr(plhs[1]),mxGetPr(prhs[2]), sizeof(double));
    imethod = (int) mxGetScalar(prhs[5]);
    reorth_(&n, &k, mxGetPr(prhs[0]), &n, mxGetPr(plhs[0]), 
      mxGetPr(plhs[1]), mxGetPr(prhs[3]), mxGetPr(prhs[4]), 
      work,&imethod,&inre);
    if (nlhs>2) 
      *(mxGetPr(plhs[2])) = (double) inre*k;
    mxFree(work);
  }
0 comentarios
Respuestas (1)
  Jan
      
      
 el 21 de Oct. de 2011
        Where is the definition of reorth_? It must be either included in reorth_mex.c or added to the mex command.
0 comentarios
Ver también
Categorías
				Más información sobre Write C Functions Callable from MATLAB (MEX Files) en Help Center y File Exchange.
			
	Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

