[英]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.