Error using mexOpenCV (line 120)
Undefined symbols for architecture x86_64:
"cv::imdecode(cv::_InputArray const&, int)", referenced from:
    _mexFunction in decodeUDPimg.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see
invocation)
#include "opencvmex.hpp"
#define _DO_NOT_EXPORT
#if defined(_DO_NOT_EXPORT)
#define DllExport  
#else
#define DllExport __declspec(dllexport)
#endif
unsigned char *InputBuffer;
int buffLen;
using namespace cv;
using namespace std;
///////////////////////////////////////////////////////////////////////////
// Check inputs
///////////////////////////////////////////////////////////////////////////
void checkInputs(int nrhs, const mxArray *prhs[])
{ 
    // Check number of inputs
    // Expecting 2 inputs: uint8 buffer, and size of buffer
    if (nrhs != 2)
    {
        mexErrMsgTxt("Incorrect number of inputs. Function expects 2 inputs.");
    }
      // Check buffer data type
      if (!mxIsUint8(prhs[0]))
      {
          mexErrMsgTxt("Buffer must be UINT8.");
      }
      if (prhs[1] == 0)
      {
          mexErrMsgTxt("Buffer length should  be positive.");
      }
  }
  ///////////////////////////////////////////////////////////////////////////
  // Main entry point to a MEX function
  ///////////////////////////////////////////////////////////////////////////
  void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
  {  
    // Check inputs to mex function
      checkInputs(nrhs, prhs);
      // process image data
      InputBuffer = (unsigned char *)mxGetData(prhs[0]);
      buffLen= (int)mxGetScalar(prhs[1]);
      Mat rawData = Mat(1, buffLen, CV_8UC1, InputBuffer);
      Mat frame = imdecode(rawData, CV_LOAD_IMAGE_COLOR);
      if (frame.size().width == 0) {
          cerr << "decode failure!" << endl;
          //plhs[0] = mxCreateDoubleScalar(0);
          //plhs[1] = mxCreateDoubleScalar(1);
          return;
      }
      // Put the data back into the output MATLAB array
      plhs[0] = ocvMxArrayFromImage_single(frame);
      return;
  }