Compiler CXXFLAGS on a Legato App



I am trying to build a very simple app using c++.
My app is as follow:

├── testComponent
│ ├── Component.cdef
│ ├── myclass.cpp
│ ├── myclass.h
│ └── test.cpp
├── testcpp.adef

This app build as long as I don’t need a particular cxxflag.

However if I add #include in myclass.h and the following in Component.cdef as explain in :

My app doesn’t build anymore and print:
c++0x_warning.h:32:2: 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.

It prints the same error if I add the cxxflags or if I remove it. It seems that the cxxflags is ignored because -std=c++11 doesn’t appear during the build.

For debugging purpose I added this flag :
And this time I could see that my flag appeared during the build but as expected I had the following error:
error: command line option ‘-std=c++11’ is valid for C++/ObjC++ but not for C [-Werror]

What am I doing wrong ?

Best reagards,

16.10.1 build with say gcc -D what's the recommended method CFLAGS


Try removing the ‘-’ from in front of the std= line in your cdef file.

Ciao, Dave


Nothing changed, I still have the same error.

Another idea ?



I can confirm the same happens here for me - both using Dev Studio and on the command line.

Let me ask some questions…

ciao, Dave



You’ve found a feature!

I’ve asked some questions and I’ve had it confirmed that the cxxflags stanza in the cdef file is not being processed correctly. A bug has been logged about this - and knowing the Legato team it will probably be fixed reasonably promptly (They’re good like that!).

There is a workaround though. If you’re using DS to do your development, you can edit the Application Project (the project with the adef file) Properties to add your desired cxx flags.

[li]Right click on the app project and select properties[/li]
[li]in the right hand pane, expand C/C++ Build and select Settings[/li]
[li]In the left hand pane you’ll see some tabs - the first (Tool Settings) should be open[/li]
[li]Select the mkapp tool, and edit the command to add --cxxflags="-std=c++11" after the command mkapp[/li]
[li]Click OK, and rebuild your Application (NOT just the Component)[/li][/ol]

I’ve tested this and confirms that it works with the include file you referenced above.

I’ve inserted an image with my modifications in case my description is a bit vague…

If you’re doing it from the command line, edit your makefile so that your mkapp line looks like so:

Hope this gets you going…

ciao, Dave

p.s. a big thanks to kmurphy for working through this with me.


Nothing more to add on DS part, except that in future DS 3.5, there will be an additional widget in C Build Options to manage flags for C++ compiler


Thanks for the help, It worked :slight_smile: