2016-08-01 83 views
-1

我嘗試使用MATLAB MEX編譯,但我不斷收到此錯誤:錯誤,而與MATLAB MEX編譯

Warning: You are using gcc version "5.4.0-6ubuntu1~16.04.1)". The version 
    currently supported with MEX is "4.2.3". 
    For a list of currently supported compilers see: 
    http://www.mathworks.com/support/compilers/current_release/ 

In file included from descriptor.h:4:0, 
       from calc_shot.cpp:11: 
mesh.h: In function ‘double magnitude(const vec3d<T>&)’: 
mesh.h:106:9: error: ‘sqrt’ is not a member of ‘std’ 
    return std::sqrt((v1.x*v1.x) + (v1.y*v1.y) + (v1.z*v1.z)); 
     ^
In file included from calc_shot.cpp:11:0: 
descriptor.h: At global scope: 
descriptor.h:7:57: error: expected class-name before ‘{’ token 
class invalid_mesh_descriptor : public std::logic_error { 
                 ^
descriptor.h: In constructor ‘invalid_mesh_descriptor::invalid_mesh_descriptor()’: 
descriptor.h:9:57: error: expected class-name before ‘(’ token 
    explicit invalid_mesh_descriptor() : std::logic_error("Exception invalid_mesh_descriptor caught.") {} 
                 ^
descriptor.h:9:57: error: expected ‘{’ before ‘(’ token 
descriptor.h: In constructor ‘invalid_mesh_descriptor::invalid_mesh_descriptor(const string&)’: 
descriptor.h:10:70: error: expected class-name before ‘(’ token 
    invalid_mesh_descriptor(const std::string& msg) : std::logic_error("Exception invalid_mesh_descriptor caught: "+msg) {} 
                    ^
descriptor.h:10:70: error: expected ‘{’ before ‘(’ token 
descriptor.h: In function ‘std::ostream& operator<<(std::ostream&, const vec_descriptor<T>&)’: 
descriptor.h:123:45: error: no match for ‘operator<<’ (operand types are ‘std::ostream {aka std::basic_ostream<char>}’ and ‘const char [2]’) 
     for (size_t k=1; k < d.size(); ++k) s << " " << d(k); 
              ^
In file included from /usr/include/c++/5/string:52:0, 
       from descriptor.h:5, 
       from calc_shot.cpp:11: 
/usr/include/c++/5/bits/basic_string.h:5172:5: note: candidate: template<class _CharT, class _Traits, class _Alloc> std::basic_ostream<_CharT, _Traits>& std::operator<<(std::basic_ostream<_CharT, _Traits>&, const std::__cxx11::basic_string<_CharT, _Traits, _Alloc>&) 
    operator<<(basic_ostream<_CharT, _Traits>& __os, 
    ^
/usr/include/c++/5/bits/basic_string.h:5172:5: note: template argument deduction/substitution failed: 
In file included from calc_shot.cpp:11:0: 
descriptor.h:123:48: note: mismatched types ‘const std::__cxx11::basic_string<_CharT, _Traits, _Alloc>’ and ‘const char [2]’ 
     for (size_t k=1; k < d.size(); ++k) s << " " << d(k); 
               ^

    mex: compile of ' "calc_shot.cpp"' failed. 

我用來編譯此代碼LD_PRELOAD但此刻我不記得的說法,我該如何解決?

+0

我注意到,所有的編譯器不包括頭一樣。您可能需要添加一些額外的標題。第一個例子,'mesh.h:106:9:error:'sqrt'不是'std'的成員。原因可能實際上是你需要'#include '。可能還有其他類似的問題,但我不確定。 – patrik

+0

另一個例子是'descriptor.h:123:45:錯誤:'operator <<'不匹配(操作數類型是'std :: ostream {aka std :: basic_ostream }'和'const char [2]') '。這可能需要'#包括' – patrik

+0

代碼是好的,我用compie它使用正確的參數,但我不記得他們 – Luca

回答

1

解決方案:

mex -v calc_shot.cpp shot_descriptor.cpp -DUSE_FLANN -I"C:\Program Files\flann\include" -I/usr/include/eigen3 

使用該命令程序的工作原理就像一個魅力