C++ Mountain Lion上的Mex文件:显式实例化错误

C++ Mountain Lion上的Mex文件:显式实例化错误,c++,matlab,C++,Matlab,我正在山狮上使用MatlabR2012B,安装的XCode版本是4.6.1。我也在使用了补丁,然后我输入了“mex-setup”并选择了唯一可用的选项 1: /Applications/MATLAB_R2012b.app/bin/mexopts.sh : Template Options file for building gcc MEX-files 我正在尝试使用一个使用mex文件的稀疏建模框架(用C++编写)。为了安装之前的框架,我必须在框架内调用一个调用mex函数的matlab文件:然而

我正在山狮上使用MatlabR2012B,安装的XCode版本是4.6.1。我也在使用了补丁,然后我输入了“mex-setup”并选择了唯一可用的选项

1: /Applications/MATLAB_R2012b.app/bin/mexopts.sh : Template Options file for building gcc MEX-files
我正在尝试使用一个使用mex文件的稀疏建模框架(用C++编写)。为了安装之前的框架,我必须在框架内调用一个调用mex函数的matlab文件:然而,当我调用此函数时,我得到以下消息

compilation of: -I./linalg/ -I./decomp/ -I./dictLearn/ dictLearn/mex/mexTrainDL.cpp
./linalg/linalg.h: In member function 'void Matrix<T>::print(const std::string&) const [with T = float]':
./linalg/linalg.h:1084:   instantiated from 'std::basic_ostream<_CharT, _Traits>& std::operator<<(std::basic_ostream<_CharT, _Traits>&, const std::basic_string<_CharT, _Traits, _Alloc>&) [with _CharT = char, _Traits = std::char_traits<char>, _Alloc = std::allocator<char>]'
./linalg/linalg.h:1084:   instantiated from 'void Matrix<T>::print(const std::string&) const [with T = float]'
dictLearn/mex/mexTrainDL.cpp:197:   instantiated from here
./linalg/linalg.h:1084: error: explicit instantiation of 'std::basic_ostream<_CharT, _Traits>& std::operator<<(std::basic_ostream<_CharT, _Traits>&, const std::basic_string<_CharT, _Traits, _Alloc>&) [with _CharT = char, _Traits = std::char_traits<char>, _Alloc = std::allocator<char>]' but no definition available
./linalg/linalg.h: At global scope:
./linalg/linalg.h: In instantiation of 'std::basic_ostream<_CharT, _Traits>& std::operator<<(std::basic_ostream<_CharT, _Traits>&, const std::basic_string<_CharT, _Traits, _Alloc>&) [with _CharT = char, _Traits = std::char_traits<char>, _Alloc = std::allocator<char>]':
./linalg/linalg.h:1084:   instantiated from 'void Matrix<T>::print(const std::string&) const [with T = float]'
dictLearn/mex/mexTrainDL.cpp:197:   instantiated from here
./linalg/linalg.h:1084: error: explicit instantiation of 'std::basic_ostream<_CharT, _Traits>& std::operator<<(std::basic_ostream<_CharT, _Traits>&, const std::basic_string<_CharT, _Traits, _Alloc>&) [with _CharT = char, _Traits = std::char_traits<char>, _Alloc = std::allocator<char>]' but no definition available
./linalg/linalg.h: In instantiation of 'std::basic_ostream<_CharT, _Traits>& std::operator<<(std::basic_ostream<_CharT, _Traits>&, const std::basic_string<_CharT, _Traits, _Alloc>&) [with _CharT = char, _Traits = std::char_traits<char>, _Alloc = std::allocator<char>]':
./linalg/linalg.h:1084:   instantiated from 'void Matrix<T>::print(const std::string&) const [with T = float]'
dictLearn/mex/mexTrainDL.cpp:197:   instantiated from here
./linalg/linalg.h:1084: error: explicit instantiation of 'std::basic_ostream<_CharT, _Traits>& std::operator<<(std::basic_ostream<_CharT, _Traits>&, const std::basic_string<_CharT, _Traits, _Alloc>&) [with _CharT = char, _Traits = std::char_traits<char>, _Alloc = std::allocator<char>]' but no definition available

mex: compile of ' "dictLearn/mex/mexTrainDL.cpp"' failed.
编译:-I./linalg/-I./decomp/-I./dictLearn/dictLearn/mex/mexTrainDL.cpp
./linalg/linalg.h:在成员函数“void Matrix::print(const std::string&)const[with T=float]”中:

/linalg/linalg.h:1084:从“std::basic_ostream&std::operator”实例化我通过行添加编译标志“-mmacosx version min=10.7”解决了这个问题

compile_flags=[compile_flags ' -mmacosx-version-min=10.7'];
在SPAMS框架的compile.m中,位于调用mex的for块之前


这个解决方案来自于其他软件包,并且似乎与其他软件包存在相同的问题。

我通过将mexopts.sh中的MACOSX_部署_TARGET='10.5'更改为'10.6'解决了类似的问题。

在线的是什么。/linalg/linalg.h:1083?该文件包含哪些标题?听起来它可能有一个转发声明(例如,来自
),但不是类模板的完整定义。您好,在第1083行有“std::cerr”,乍一看,作者似乎没有包括其中包含stderr,但当我在雪豹上编译时,使用了以前版本的Xcode(和Matlab 2012a)没有问题!!!似乎fstream以前包括iostream,但现在没有了。解决方案可能很简单,只需将该文件更改为包含它。我曾尝试将#include添加到linalg.h中,但出现了相同的错误。
/// Print the matrix to std::cout
template <typename T> inline void Matrix<T>::print(const string& name) const {
   std::cerr << name << std::endl;
   std::cerr << _m << " x " << _n << std::endl;
   for (int i = 0; i<_m; ++i) {
      for (int j = 0; j<_n; ++j) {
         printf("%10.5g ",static_cast<double>(_X[j*_m+i]));
         //         std::cerr << _X[j*_m+i] << " ";
      }
      printf("\n ");
      //std::cerr << std::endl;
   }
   printf("\n ");
};
template <typename T> void ShiftMatrix<T>::print(const string& name) const {
   cerr << name << endl;
   cerr << "Shift Matrix: " << _shifts << " shifts" << endl;
   _inputmatrix->print(name);
};
template <typename T> void DoubleRowMatrix<T>::print(const string& name) const {
   cerr << name << endl;
   cerr << "Double Row Matrix" << endl;
   _inputmatrix->print(name);
};
cerr << name << endl;
compile_flags=[compile_flags ' -mmacosx-version-min=10.7'];