Mex 找不到 g++

Mex can't find g++

我是 MatLab 的新手,我正在尝试通过 Redhat 上的 Matlab 使用 mex 编译一个 .cpp 文件。以下是我命令的输出

mex myfile.cpp-v

No MEX options file identified; looking for an implicit selection.
... Looking for compiler 'g++' ...
... Executing command 'which g++' ...Yes ('/bin/g++').
... Executing command 'g++ -print-file-name=libstdc++.so' ...Yes ('/usr/lib/gcc/x86_64-redhat-linux/4.8.5/libstdc++.so').
... Executing command 'g++ -dumpversion' ...Yes ('4.8.5').
... Executing command 'which g++' ...Yes ('/bin/g++').
... Looking for folder '' ...No.

Did not find installed compiler 'g++'.
Error using mex
No supported compiler was found. For options, visit https://www.mathworks.com/support/compilers.

如何编译这个文件?

whereis g++ 输出

g++: /usr/bin/g++ /usr/share/man/man1/g++.1.gz

MatLab版本为2018R

您的 gcc-4.8.5 版本太旧。错误消息 http://mathworks.com/support/requirements/supported-compilers.html 中的 link 列出了对 linux 上 gcc-6.3.X 的支持。请将您的编译器升级到 gcc-6.3 或更高版本。