# Compiler CXXFLAGS on a Legato App

**URL:** <https://forum.legato.io/t/compiler-cxxflags-on-a-legato-app/157>\
**Category:** Legato Application Framework\
**Created:** [August 19, 2015, 10:24am UTC](https://forum.legato.io/t/compiler-cxxflags-on-a-legato-app/157 "2015-08-19T10:24:35Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![totosdf](https://avatars.discourse-cdn.com/v4/letter/t/6f9a4e/32.png) [@totosdf](https://forum.legato.io/u/totosdf)\
**Post date:** [August 19, 2015, 10:24am UTC](https://forum.legato.io/t/compiler-cxxflags-on-a-legato-app/157/1 "2015-08-19T10:24:35Z")

</div>

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](http://www.legato.io/legato-docs/15_05/def_files_cdef.html#defFilesCdef_cxxFlags%5B/url%5D) :  
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,

---

<div class="post-metadata">

**Author:** ![davidc](https://avatars.discourse-cdn.com/v4/letter/d/a183cd/32.png) [@davidc](https://forum.legato.io/u/davidc)\
**Post date:** [August 19, 2015, 10:58am UTC](https://forum.legato.io/t/compiler-cxxflags-on-a-legato-app/157/2 "2015-08-19T10:58:06Z")

</div>

Hiya,

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

Ciao, Dave

---

<div class="post-metadata">

**Author:** ![totosdf](https://avatars.discourse-cdn.com/v4/letter/t/6f9a4e/32.png) [@totosdf](https://forum.legato.io/u/totosdf)\
**Post date:** [August 19, 2015, 12:06pm UTC](https://forum.legato.io/t/compiler-cxxflags-on-a-legato-app/157/3 "2015-08-19T12:06:14Z")

</div>

Nothing changed, I still have the same error.

Another idea ?

---

<div class="post-metadata">

**Author:** ![davidc](https://avatars.discourse-cdn.com/v4/letter/d/a183cd/32.png) [@davidc](https://forum.legato.io/u/davidc)\
**Post date:** [August 21, 2015, 1:35am UTC](https://forum.legato.io/t/compiler-cxxflags-on-a-legato-app/157/4 "2015-08-21T01:35:43Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![davidc](https://avatars.discourse-cdn.com/v4/letter/d/a183cd/32.png) [@davidc](https://forum.legato.io/u/davidc)\
**Post date:** [August 22, 2015, 11:58am UTC](https://forum.legato.io/t/compiler-cxxflags-on-a-legato-app/157/5 "2015-08-22T11:58:21Z")

</div>

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:

```auto
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.

---

<div class="post-metadata">

**Author:** ![daav](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.legato.io/daav/32/64_2.png) [@daav](https://forum.legato.io/u/daav)\
**Post date:** [August 24, 2015, 7:18am UTC](https://forum.legato.io/t/compiler-cxxflags-on-a-legato-app/157/6 "2015-08-24T07:18:15Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![totosdf](https://avatars.discourse-cdn.com/v4/letter/t/6f9a4e/32.png) [@totosdf](https://forum.legato.io/u/totosdf)\
**Post date:** [August 24, 2015, 10:21am UTC](https://forum.legato.io/t/compiler-cxxflags-on-a-legato-app/157/7 "2015-08-24T10:21:10Z")

</div>

Thanks for the help, It worked 🙂
