Compiler CXXFLAGS on a Legato App

Hi,

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

testcpp
├── 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 [url]LEGATO: Component Definition .cdef :
cxxflags:
{
-std=c++11
}

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 :
cflags:
{
-std=c++11
}
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,

Hiya,

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 ?

Hiya,

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

Hiya,

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.

[ol]
[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…
[attachment=0]20150822-legato-cxxflags.png[/attachment]

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

mkapp  --cxxflags="-std=c++11" <myapp>.adef -t wp85

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: