Problem compiling mex files using visual studio.
显示 更早的评论
I'm currently using a patch to compile mex files using visual studio 2010 ( http://www.mathworks.com/support/solutions/en/data/1-D5W493/?solution=1-D5W493).
I was able to compile many files but I am having trouble trying to compile an implementation of a decision tree ( http://www.cs.uiuc.edu/homes/dhoiem/software/counter.php?Down=boostDt.zip)
The errors that the mex compiler is giving to me do not make any sense. Does someone had any problem like that?
>> mex treevalc.c
treevalc.c
treevalc.c(26) : warning C4101: 'cid' : unreferenced local variable
treevalc.c(92) : error C2143: syntax error : missing ';' before 'type'
treevalc.c(93) : error C2143: syntax error : missing ';' before 'type'
treevalc.c(94) : error C2143: syntax error : missing ';' before 'type'
treevalc.c(95) : error C2143: syntax error : missing ';' before 'type'
treevalc.c(97) : error C2143: syntax error : missing ';' before 'type'
treevalc.c(98) : error C2143: syntax error : missing ';' before 'type'
treevalc.c(99) : error C2143: syntax error : missing ';' before 'type'
treevalc.c(101) : error C2143: syntax error : missing ';' before 'type'
treevalc.c(102) : error C2065: 'n' : undeclared identifier
treevalc.c(102) : error C2065: 'n' : undeclared identifier
treevalc.c(102) : error C2065: 'nsplits' : undeclared identifier
treevalc.c(102) : error C2065: 'n' : undeclared identifier
treevalc.c(103) : error C2065: 'n' : undeclared identifier
treevalc.c(107) : error C2065: 'ncatsplit' : undeclared identifier
treevalc.c(107) : error C2065: 'n' : undeclared identifier
treevalc.c(107) : error C2109: subscript requires array or pointer type
treevalc.c(108) : error C2065: 'catsplit' : undeclared identifier
treevalc.c(108) : error C2065: 'n' : undeclared identifier
treevalc.c(108) : error C2109: subscript requires array or pointer type
treevalc.c(111) : error C2143: syntax error : missing ';' before 'type'
treevalc.c(112) : error C2143: syntax error : missing ';' before 'type'
treevalc.c(116) : error C2143: syntax error : missing ';' before 'type'
treevalc.c(118) : error C2065: 'numdata' : undeclared identifier
treevalc.c(119) : error C2143: syntax error : missing ';' before 'type'
treevalc.c(122) : error C2143: syntax error : missing ';' before 'type'
treevalc.c(123) : error C2065: 'n' : undeclared identifier
treevalc.c(123) : error C2065: 'n' : undeclared identifier
treevalc.c(123) : error C2065: 'numdata' : undeclared identifier
treevalc.c(123) : error C2065: 'n' : undeclared identifier
treevalc.c(124) : error C2065: 'var' : undeclared identifier
treevalc.c(124) : warning C4047: 'function' : 'int *' differs in levels of indirection from 'int'
treevalc.c(124) : warning C4024: 'treevalc' : different types for formal and actual parameter 1
treevalc.c(124) : error C2065: 'cut' : undeclared identifier
treevalc.c(124) : warning C4047: 'function' : 'double *' differs in levels of indirection from 'int'
treevalc.c(124) : warning C4024: 'treevalc' : different types for formal and actual parameter 2
treevalc.c(124) : error C2065: 'left_child' : undeclared identifier
treevalc.c(124) : warning C4047: 'function' : 'int *' differs in levels of indirection from 'int'
treevalc.c(124) : warning C4024: 'treevalc' : different types for formal and actual parameter 3
treevalc.c(124) : error C2065: 'right_child' : undeclared identifier
treevalc.c(124) : warning C4047: 'function' : 'int *' differs in levels of indirection from 'int'
treevalc.c(124) : warning C4024: 'treevalc' : different types for formal and actual parameter 4
treevalc.c(124) : error C2065: 'ncatsplit' : undeclared identifier
treevalc.c(124) : warning C4047: 'function' : 'int *' differs in levels of indirection from 'int'
treevalc.c(124) : warning C4024: 'treevalc' : different types for formal and actual parameter 5
treevalc.c(124) : error C2065: 'catsplit' : undeclared identifier
treevalc.c(124) : warning C4047: 'function' : 'double **' differs in levels of indirection from 'int'
treevalc.c(124) : warning C4024: 'treevalc' : different types for formal and actual parameter 6
treevalc.c(125) : error C2065: 'all_attributes' : undeclared identifier
treevalc.c(125) : error C2065: 'numatt' : undeclared identifier
treevalc.c(125) : error C2065: 'n' : undeclared identifier
treevalc.c(125) : error C2109: subscript requires array or pointer type
treevalc.c(125) : error C2065: 'tmp_id' : undeclared identifier
treevalc.c(125) : warning C4133: 'function' : incompatible types - from 'int *' to 'double *'
treevalc.c(125) : error C2198: 'treevalc' : too few arguments for call
treevalc.c(126) : error C2065: 'node_ids' : undeclared identifier
treevalc.c(126) : error C2065: 'n' : undeclared identifier
treevalc.c(126) : error C2109: subscript requires array or pointer type
treevalc.c(126) : error C2065: 'tmp_id' : undeclared identifier
treevalc.c(130) : error C2065: 'catsplit' : undeclared identifier
treevalc.c(130) : warning C4022: 'free' : pointer mismatch for actual parameter 1
treevalc.c(131) : error C2065: 'ncatsplit' : undeclared identifier
treevalc.c(131) : warning C4022: 'free' : pointer mismatch for actual parameter 1
C:\PROGRA~1\MATLAB\R2009B\BIN\MEX.PL: Error: Compile of 'treevalc.c' failed.
4 个评论
James Tursa
2012-12-18
Can you post your code?
Jan
2012-12-18
Please post the lines 91 an 92 of treevalc.c. How could we guess the problem without knowing the source code?
Hadok
2012-12-19
Hadok
2012-12-19
采纳的回答
更多回答(2 个)
Some ideas which do not solve your actual problem:
if (nrhs != 6) {
printf("Error: wrong number of input arguments: %d.\n", nlhs);
You check nrhs but print nlhs.
Is printf defined or do you have to call mexPrintf?
Concerning your problem:
Is this compiled as C89? Then the declarations have to appear before any non-declaration code in each function. See last point of http://msdn.microsoft.com/en-us/library/vstudio/0afb82ta.aspx.
It is strange to convert the value of the input array to "int": This will crash, when the "int" has not as many bits as you expect. Better use "int32_T", if the Matlab array is a int32 - and be sure to check this explicitly:
if (!mxIsInt32(prhs[0])) { ...
Walter Roberson
2012-12-19
0 个投票
Notice that the problem occurs at the very first place that uses mxArray . The problem is as-if mex.h is not complete.
Was mex.h supplied as part of the source code? If so then that mex.h would override mex.h expected to be supplied by the "mex" command.
类别
在 帮助中心 和 File Exchange 中查找有关 Write C Functions Callable from MATLAB (MEX Files) 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!