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

12 ビュー (過去 30 日間)
Ashley Stephenson
Ashley Stephenson 2016 年 6 月 15 日
回答済み: Paul Rötzer 2022 年 7 月 15 日
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.

採用された回答

Titus Edelhofer
Titus Edelhofer 2016 年 6 月 16 日
Hi Ashley,
try to add the flag to the compiler options like this:
mex -v COMPFLAGS='$COMPFLAGS -std=c++11' yourmexfile.c
Titus
  4 件のコメント
JEROME GARCIA
JEROME GARCIA 2018 年 2 月 15 日
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
michael bronnmann
michael bronnmann 2020 年 6 月 8 日
This works fine using mex-command. But how to set this compile flag for rtw-build?

サインインしてコメントする。

その他の回答 (1 件)

Paul Rötzer
Paul Rötzer 2022 年 7 月 15 日
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

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by