MATLAB Answers

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

44 views (last 30 days)
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.

  0 Comments

Sign in to comment.

Accepted Answer

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

  3 Comments

Ashley Stephenson
Ashley Stephenson on 16 Jun 2016
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!
Yevgeniy Yesilevskiy
Yevgeniy Yesilevskiy on 9 Aug 2017
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?
JEROME GARCIA
JEROME GARCIA on 15 Feb 2018
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

Sign in to comment.

More Answers (0)

Sign in to answer this question.