How to enable compiler options for ISO C++ 2011 standard in MATLAB R2016a

I am receiving the below error when trying to compile a cpp file using mex. Mex is configured to use 'MinGW64 Compiler (C++)' for C++ language compilation, but I am wondering how to go about enabling the compiler options stated in the error message. Steps for how to do this would be appreciated.
error: #error This file requires compiler and library support for the ISO C++ 2011 standard. This support is currently experimental, and must be enabled with the -std=c++11 or -std=gnu++11 compiler options.

 Respuesta aceptada

Hi Ashley,
try to add the flag to the compiler options like this:
mex -v COMPFLAGS='$COMPFLAGS -std=c++11' yourmexfile.c
Titus

4 comentarios

Thanks for your help. This helped with part of the problem I was having, but I ended up switching to visual studio and it fixed the rest of the issue. Appreciate the help!
I've tried using the flag you put there, but I still receive the error:
#error This file requires compiler and library support for the ISO C++ 2011 standard. This support is currently
experimental, and must be enabled with the -std=c++11 or -std=gnu++11 compiler options.
I'm testing with a simple "Hello World" printout, with the addition of
#include <array>
Any suggestions on what else to do?
Thanks for the info. On my side in order to have the latest C++17 features, like any I used
mex COMPFLAGS=''$COMPFLAGS /std:c++latest'' yourmexfile.cpp
and it worked fine,
regards, Jérôme
This works fine using mex-command. But how to set this compile flag for rtw-build?

Iniciar sesión para comentar.

Más respuestas (1)

It didn't work for me on MacOS. Following Mex Documentation i could see that for MacOS, MinGW and Linux compilers the following hast to be done:
mex -v CXXFLAGS='$CXXFLAGS -std=c++11' yourmexfile.c

Categorías

Más información sobre Write C Functions Callable from MATLAB (MEX Files) en Centro de ayuda y File Exchange.

Etiquetas

Preguntada:

el 15 de Jun. de 2016

Respondida:

el 15 de Jul. de 2022

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by