C++ 编译C++;使用MEX文件
我需要编译cpp代码,但得到以下消息: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
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);