[英]Problems building with G++ on MATLAB
我对MATLAB有点陌生,但目前正在尝试使用G ++(版本6.3)作为编译器来构建MEX文件。 我得到这个错误
MEX completed successfully.
Building with 'g++'.
Error using mex
/disks/local/sceneflow2/./external/libtrws/trwsMex.cpp:14:13: error: conflicting declaration ‘typedef
int mwSize’
In file included from /usr/local/MATLAB/R2016a/extern/include/matrix.h:25:0,
from /usr/local/MATLAB/R2016a/extern/include/mex.h:51,
from /disks/local/sceneflow2/./external/libtrws/trwsMex.cpp:9:
/usr/local/MATLAB/R2016a/extern/include/tmwtypes.h:795:19: error: ‘mwSize’ has a previous
declaration as ‘typedef size_t mwSize’
/disks/local/sceneflow2/./external/libtrws/trwsMex.cpp:15:13: error: conflicting declaration ‘typedef
int mwIndex’
In file included from /usr/local/MATLAB/R2016a/extern/include/matrix.h:25:0,
from /usr/local/MATLAB/R2016a/extern/include/mex.h:51,
from /disks/local/sceneflow2/./external/libtrws/trwsMex.cpp:9:
/usr/local/MATLAB/R2016a/extern/include/tmwtypes.h:796:19: error: ‘mwIndex’ has a previous
declaration as ‘typedef size_t mwIndex’
Error in make_mex (line 20)
mex ./external/libtrws/trwsMex.cpp -largeArrayDims CXXFLAGS="\$CXXFLAGS -std=c++0x -fpermissive"
-outdir build
我不明白 为什么mwSize
/usr/local/MATLAB/R2016a/extern/include/tmwtypes.h
定义与/usr/local/MATLAB/R2016a/extern/include/mex.h
冲突? 它们不是MATLAB随附的预定义库吗(意味着它们应该可以正常工作?)
顺便说一句,/ /disks/local/sceneflow2/./external/libtrws/trwsMex.cpp
中的一行包含上述的mex.h
错误消息必须阻止(针对两个不同的错误),让我们仅看第一个。 我将其分为三个“行”:
/disks/local/sceneflow2/./external/libtrws/trwsMex.cpp:14:13: error: conflicting declaration 'typedef int mwSize' In file included from /usr/local/MATLAB/R2016a/extern/include/matrix.h:25:0, from /usr/local/MATLAB/R2016a/extern/include/mex.h:51, from /disks/local/sceneflow2/./external/libtrws/trwsMex.cpp:9: /usr/local/MATLAB/R2016a/extern/include/tmwtypes.h:795:19: error: 'mwSize' has a previous declaration as 'typedef size_t mwSize'
第一行说,编译器在trwsMex.cpp
文件的第14行找到了mwSize
的声明, mwSize
声明typedef int mwSize
。
最后一行说此mwSize
已在MATLAB随附的tmwtypes.h
标头中定义。
第二行说此头文件包含在matrix.h
,它包含在mex.h
,该文件包含在第9行的trwsMex.cpp
。
因此,要解决该错误,请不要在MEX文件源代码中定义mwSize
和mwIndex
,它们是由MATLAB的标头定义的。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.