Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/matlab/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ 编译C++;使用MEX文件_C++_Matlab_Mex - Fatal编程技术网

C++ 编译C++;使用MEX文件

C++ 编译C++;使用MEX文件,c++,matlab,mex,C++,Matlab,Mex,我需要编译cpp代码,但得到以下消息: Building with 'Xcode Clang++'. Error using mex ~/code_sparse_group_lasso/linNest.cpp:395:2: error: no matching function for call to 'linNest' linNest(X, y, index, nrow, ncol, numGroup, rangeGroupInd, groupLen, lamb

我需要编译cpp代码,但得到以下消息:

Building with 'Xcode Clang++'.
Error using mex
~/code_sparse_group_lasso/linNest.cpp:395:2:
error: no matching function for call to 'linNest'
        linNest(X, y, index, nrow, ncol, numGroup, rangeGroupInd, groupLen,
        lambda1, lambda2, beta, innerIter, outerIter, thresh, outerThresh,
        eta, gamma, betaIsZero, step, reset);
        ^~~~~~~
~/code_sparse_group_lasso/linNest.cpp:276:6:
note: candidate function not viable: no known conversion from 'int' to 'int
*' for 3rd argument; take the address of the argument with &
void linNest(double *X, double* y, int *index, int *nrow, int *ncol, int
*numGroup, int *rangeGroupInd, int *groupLen, double *lambda1, double
*lambda2, double *beta, int *innerIter, int *outerIter, double *thresh,
double *outerThresh, double *eta, double *gamma, int *betaIsZero, double
*step, int *reset)
     ^
1 error generated.

我认为错误源于没有正确指定变量。有人能帮忙吗?

错误消息告诉您“候选函数不可行:对于第三个参数,没有从'int'到'int*'的已知转换;使用&'获取参数的地址”。您一定要尝试这样做,更改当前行:

linNest(X, y, index, nrow, ncol, numGroup, rangeGroupInd, groupLen, lambda1, lambda2, beta, innerIter, outerIter, thresh, outerThresh, eta, gamma, betaIsZero, step, reset);
致:

这使得类型匹配

我查看了代码,
linNest
索引
指针转发到
linSolver
,而该函数根本不使用指针。也就是说,
索引不在代码中使用。我不知道这是一个bug还是故意的,但是因为它没有被使用,做上面的更改肯定不会有危险。您也可以用
nullptr
替换
index

linNest(X, y, &index, nrow, ncol, numGroup, rangeGroupInd, groupLen, lambda1, lambda2, beta, innerIter, outerIter, thresh, outerThresh, eta, gamma, betaIsZero, step, reset);