Problem compiling mex files using visual studio.
4 views (last 30 days)
Show older comments
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 Comments
Accepted Answer
Hadok
on 19 Dec 2012
3 Comments
Omar
on 19 Jun 2013
Hadok, would you please explain what you eventually did to mex treevalc.c. Is it possible to change on VS10 compiler to resolve this problem? Thanks.
Rajen Bhatt
on 12 Jan 2015
Jan and Hadok: Can you guys please elaborate how you have resolved this problem? I am trying to compile treevalc.c file on Windows MATLAB 2013b and it is giving me same errors which Hadok has described earlier. This is so crucial for my program that without it I can not move further. Your help will be much appreciated. If you want to share compiled mexw, that too is welcome !
More Answers (2)
Jan
on 19 Dec 2012
Edited: Jan
on 19 Dec 2012
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])) { ...
0 Comments
Walter Roberson
on 19 Dec 2012
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.
0 Comments
See Also
Categories
Find more on Write C Functions Callable from MATLAB (MEX Files) in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!