2012-10-23 25 views
1

這是解開並通過其使用霍夫曼編碼鏈接壓縮圖像的代碼。使用matlab解散huffman中的鏈接和解碼函數的錯誤

 
#include "mex.h" 
    void unrav(uint16_T *hx, double *link, double *x, double xsz,int hxsz) 
    { 
     int i=15; 
     int j=0, k=0, n=0; 
     while (xsz-k) 
     { 
      if (*(link + n) >0) { 
      if ((*(hx + j) >> i) & 0x0001) 
       n=*(link + n); 
      else n=*(link + n) - 1; 
       if (i) i--; else { j++; i= 15;} 
        if (j>hxsz) 
         mexErrMsgTxt("Out of cod ebits ???"); 
         } 
        else { 
          *(x + k++) =-*(link +n); 
          n=0; } 
         } 
         if (k== xsz -1) 
          *(x+ k++) =-*(link +n); 
          } 
          void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) 
          { 
           double *link, *x, xsz; 
           uint16_T *hx; 
           int hxsz; 
           if(nrhs !=3) 
           mexErrMsgTxt("Three inputs required."); 
           else if (nlhs>1) 
             mexErrMSgTxt("Too many output arguments."); 
             if(!mxIsDouble(prhs[2]) || mxIsComplex(prhs[2]) || 
              mxGetN(prhs[2])*mxGetM(prhs[2]) !=1) 
              mexErrMsgTxt("Input size must be a scalar"); 
              hx=(uint16_T *) mxGetData(prhs[0]); 
              link=(double*) mxGetData(prhs[1]); 
              xsz=mxGetScalar(prhs[2]); 
              hxsz=mxGetM(prhs[0]); 
              plhs[0]=mxCreateDoubleMatrix(xsz, 1, mxREAL); 
              x=(double *) mxGetData(plhs[0]); 
              unrav(hx, link, x, xsz, hxsz); 
           } 

這是我繹的程序,但在執行它的MATLAB R2012a它顯示了這樣的錯誤:

 
Undefined symbols for architecture x86_64: 
     "_mexErrMSgTxt", referenced from: 
      _mexFunction in unrav.o 
    ld: symbol(s) not found for architecture x86_64 
    collect2: ld returned 1 exit status 
     mex: link of ' "unrav.mexmaci64"' failed. 

我使用的是Mac OSX 10.7.2獅子和我的Xcode 4.2,但我試圖編譯它,但不支持mex.h文件

我知道該程序是好的,但我不知道我在做什麼?請任何身體幫助我。

+0

歡迎來到SO :-)只是:請編輯你的問題,並格式化代碼(有一個問號按鈕點擊學習如何) - 作爲 - 這是不可讀的 – kleopatra

回答

0

要調用的正確函數是mexErrMsgTxt。函數名稱區分大小寫。你拼錯了,所以連接器找不到它:

mexErrMSgTxt("Too many output arguments."); 
相關問題