简体   繁体   English

在MATLAB上使用G ++构建问题

[英]Problems building with G++ on MATLAB

I'm a bit new to MATLAB but am currently trying to build MEX files using G++ (version 6.3) as the compiler. 我对MATLAB有点陌生,但目前正在尝试使用G ++(版本6.3)作为编译器来构建MEX文件。 I got this error 我得到这个错误

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

I don't get it. 我不明白 Why is /usr/local/MATLAB/R2016a/extern/include/tmwtypes.h definition of mwSize conflicting with /usr/local/MATLAB/R2016a/extern/include/mex.h ? 为什么mwSize /usr/local/MATLAB/R2016a/extern/include/tmwtypes.h定义与/usr/local/MATLAB/R2016a/extern/include/mex.h冲突? Aren't they predefined libraries included with MATLAB (meaning they should work fine?) 它们不是MATLAB随附的预定义库吗(意味着它们应该可以正常工作?)

By the way, /disks/local/sceneflow2/./external/libtrws/trwsMex.cpp has a line which includes the aforementioned mex.h . 顺便说一句,/ /disks/local/sceneflow2/./external/libtrws/trwsMex.cpp中的一行包含上述的mex.h

The error message has to blocks (for two different errors), let's look at the first one only. 错误消息必须阻止(针对两个不同的错误),让我们仅看第一个。 I've split it out into three "lines": 我将其分为三个“行”:

 /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' 

The first line says that the compiler found a declaration for mwSize on line 14 of your trwsMex.cpp file, where it says typedef int mwSize . 第一行说,编译器在trwsMex.cpp文件的第14行找到了mwSize的声明, mwSize声明typedef int mwSize

The last line says that this mwSize was already defined in the tmwtypes.h header that comes with MATLAB. 最后一行说此mwSize已在MATLAB随附的tmwtypes.h标头中定义。

The second line says that this header file was included by matrix.h , which is included by mex.h , which is included by your trwsMex.cpp on line 9. 第二行说此头文件包含在matrix.h ,它包含在mex.h ,该文件包含在第9行的trwsMex.cpp


So, to fix the error, don't define mwSize and mwIndex in your MEX-file source code, these are defined by MATLAB's headers. 因此,要解决该错误,请不要在MEX文件源代码中定义mwSizemwIndex ,它们是由MATLAB的标头定义的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM