参考GNU Octave文档得到解决方案:
The first line #include "mex.h"
makes available all of the definitions necessary for a mex-file. One important difference between Octave and MATLAB is that the header file "matrix.h"
is implicitly included through the inclusion of "mex.h"
. This is necessary to avoid a conflict with the Octave file "Matrix.h"
for operating systems and compilers that don’t distinguish between filenames in upper and lower case.
原因是原文件是为MATLAB写的,在用免费软件Octave软件编译的时候,只需要#include "mex.h"头文件就可以了,把要编译的cpp文件中的#include "matrix.h"行删除即可。