VL_feat Matlab GCC无法编译

时间:2018-03-20 06:06:31

标签: c++ matlab vlfeat

我试图按照这里的说明在matlab中编译函数c_eoverlap

http://www.robots.ox.ac.uk/~vgg/research/affine/evaluation.html#eval_soft

当然,它不会有用......我的Matlab版本是2018a,这是一个非常新的,gcc -v输出以下

enter image description here

另外附上这个长错误日志,因为我是C ++的新手,请告诉我是否还需要其他信息,感谢您的帮助!

>> mex repeatability/c_eoverlap.cxx
Building with 'Xcode Clang++'.
Error using mex
/Users/lucius/Desktop/ua/805/a1/repeatability/c_eoverlap.cxx:34:14: error: cannot initialize
a variable of type 'const int *' with an rvalue of type 'const mwSize *' (aka 'const unsigned
long *')
  int const *dims1 = mxGetDimensions(prhs[0]);
             ^       ~~~~~~~~~~~~~~~~~~~~~~~~
/Users/lucius/Desktop/ua/805/a1/repeatability/c_eoverlap.cxx:36:14: error: cannot initialize
a variable of type 'const int *' with an rvalue of type 'const mwSize *' (aka 'const unsigned
long *')
  int const *dims2 = mxGetDimensions(prhs[1]);
             ^       ~~~~~~~~~~~~~~~~~~~~~~~~
/Users/lucius/Desktop/ua/805/a1/repeatability/c_eoverlap.cxx:38:14: error: cannot initialize
a variable of type 'const int *' with an rvalue of type 'const mwSize *' (aka 'const unsigned
long *')
  int const *dims3 = mxGetDimensions(prhs[2]);
             ^       ~~~~~~~~~~~~~~~~~~~~~~~~
/Users/lucius/Desktop/ua/805/a1/repeatability/c_eoverlap.cxx:46:13: error: no matching
function for call to 'mxCreateNumericArray_730'
  plhs[0] = mxCreateNumericArray(2, odim, mxDOUBLE_CLASS, mxREAL);
            ^~~~~~~~~~~~~~~~~~~~
/Applications/MATLAB_R2018a.app/extern/include/matrix.h:282:30: note: expanded from macro
'mxCreateNumericArray'
#define mxCreateNumericArray mxCreateNumericArray_730
                             ^~~~~~~~~~~~~~~~~~~~~~~~
/Applications/MATLAB_R2018a.app/extern/include/matrix.h:1256:1: note: candidate function not
viable: no known conversion from 'int *' to 'const mwSize *' (aka 'const unsigned long *')
for 2nd argument
mxCreateNumericArray(mwSize ndim, const mwSize *dims, mxClassID classid, mxComplexity flag);
^
/Applications/MATLAB_R2018a.app/extern/include/matrix.h:282:30: note: expanded from macro
'mxCreateNumericArray'
#define mxCreateNumericArray mxCreateNumericArray_730
                             ^
/Users/lucius/Desktop/ua/805/a1/repeatability/c_eoverlap.cxx:47:13: error: no matching
function for call to 'mxCreateNumericArray_730'
  plhs[1] = mxCreateNumericArray(2, odim, mxDOUBLE_CLASS, mxREAL);
            ^~~~~~~~~~~~~~~~~~~~
/Applications/MATLAB_R2018a.app/extern/include/matrix.h:282:30: note: expanded from macro
'mxCreateNumericArray'
#define mxCreateNumericArray mxCreateNumericArray_730
                             ^~~~~~~~~~~~~~~~~~~~~~~~
/Applications/MATLAB_R2018a.app/extern/include/matrix.h:1256:1: note: candidate function not
viable: no known conversion from 'int *' to 'const mwSize *' (aka 'const unsigned long *')
for 2nd argument
mxCreateNumericArray(mwSize ndim, const mwSize *dims, mxClassID classid, mxComplexity flag);
^
/Applications/MATLAB_R2018a.app/extern/include/matrix.h:282:30: note: expanded from macro
'mxCreateNumericArray'
#define mxCreateNumericArray mxCreateNumericArray_730
                             ^
/Users/lucius/Desktop/ua/805/a1/repeatability/c_eoverlap.cxx:48:13: error: no matching
function for call to 'mxCreateNumericArray_730'
  plhs[2] = mxCreateNumericArray(2, odim, mxDOUBLE_CLASS, mxREAL);
            ^~~~~~~~~~~~~~~~~~~~
/Applications/MATLAB_R2018a.app/extern/include/matrix.h:282:30: note: expanded from macro
'mxCreateNumericArray'
#define mxCreateNumericArray mxCreateNumericArray_730
                             ^~~~~~~~~~~~~~~~~~~~~~~~
/Applications/MATLAB_R2018a.app/extern/include/matrix.h:1256:1: note: candidate function not
viable: no known conversion from 'int *' to 'const mwSize *' (aka 'const unsigned long *')
for 2nd argument
mxCreateNumericArray(mwSize ndim, const mwSize *dims, mxClassID classid, mxComplexity flag);
^
/Applications/MATLAB_R2018a.app/extern/include/matrix.h:282:30: note: expanded from macro
'mxCreateNumericArray'
#define mxCreateNumericArray mxCreateNumericArray_730
                             ^
/Users/lucius/Desktop/ua/805/a1/repeatability/c_eoverlap.cxx:49:13: error: no matching
function for call to 'mxCreateNumericArray_730'
  plhs[3] = mxCreateNumericArray(2, odim, mxDOUBLE_CLASS, mxREAL);
            ^~~~~~~~~~~~~~~~~~~~
/Applications/MATLAB_R2018a.app/extern/include/matrix.h:282:30: note: expanded from macro
'mxCreateNumericArray'
#define mxCreateNumericArray mxCreateNumericArray_730
                             ^~~~~~~~~~~~~~~~~~~~~~~~
/Applications/MATLAB_R2018a.app/extern/include/matrix.h:1256:1: note: candidate function not
viable: no known conversion from 'int *' to 'const mwSize *' (aka 'const unsigned long *')
for 2nd argument
mxCreateNumericArray(mwSize ndim, const mwSize *dims, mxClassID classid, mxComplexity flag);
^
/Applications/MATLAB_R2018a.app/extern/include/matrix.h:282:30: note: expanded from macro
'mxCreateNumericArray'
#define mxCreateNumericArray mxCreateNumericArray_730
                             ^
/Users/lucius/Desktop/ua/805/a1/repeatability/c_eoverlap.cxx:198:3: warning: 'delete[]'
applied to a pointer that was allocated with 'new'; did you mean 'delete'?
[-Wmismatched-new-delete]
  delete []tdesc_out;
  ^     ~~~

/Users/lucius/Desktop/ua/805/a1/repeatability/c_eoverlap.cxx:62:22: note: allocated with
'new' here
  float *tdesc_out = new float[dims2[1]*dims1[1]];
                     ^
/Users/lucius/Desktop/ua/805/a1/repeatability/c_eoverlap.cxx:199:3: warning: 'delete[]'
applied to a pointer that was allocated with 'new'; did you mean 'delete'?
[-Wmismatched-new-delete]
  delete []tover_out;
  ^     ~~~

/Users/lucius/Desktop/ua/805/a1/repeatability/c_eoverlap.cxx:63:22: note: allocated with
'new' here
  float *tover_out = new float[dims2[1]*dims1[1]];
                     ^
2 warnings and 7 errors generated.

1 个答案:

答案 0 :(得分:1)

您需要在-compatibleArrayDims命令中添加mex

mex -compatibleArrayDims c_eoverlap.cxx 

代码是为较旧的MATLAB编写的,这些MATLAB使用32位整数(int)来表示数组大小。现在这些是64位(mwSize)。此选项强制接口像在较旧的MATLAB中一样工作。有关详细信息,请参阅Fiddle Link

关于使用delete[]代替delete,有一些可怕的警告。它只是警告,所以它会编译,但你不知道代码是否会按预期执行。