# C++ mkapp problem - WP7607-1

**URL:** https://forum.legato.io/t/c-mkapp-problem-wp7607-1/5440
**Category:** Legato Application Framework
**Created:** [October 7, 2020, 1:54pm UTC](https://forum.legato.io/t/c-mkapp-problem-wp7607-1/5440 "2020-10-07T13:54:24Z")
**Posts on this page:** 8
**Page:** 1

<div class="post-metadata">

### Author: ![tadera](https://avatars.discourse-cdn.com/v4/letter/t/f14d63/32.png) [@tadera](https://forum.legato.io/u/tadera)
#### Post date: [October 7, 2020, 1:54pm UTC](https://forum.legato.io/t/c-mkapp-problem-wp7607-1/5440/1 "2020-10-07T13:54:24Z")

</div>

Hi everyone,

I’m trying to implement a small C++ sample but get the following error when building the app:

> mkapp -t wp76xx helloCPP.adef  
> [1/1] Regenerating build script  
> [3/9] Compiling C++ source  
> FAILED: \_build\_helloCPP/wp76xx/component/b130cd0656327c8de99a44179d5831dc/obj/4c01286321aa8b611d1cea84c8618f67.o  
> /home/mangoh/workspace/leaf-data/wp76stable/wp76-toolchain/sysroots/x86\_64-pokysdk-linux/usr/bin/arm-poky-linux-gnueabi/arm-poky-linux-gnueabi-g++ --sysroot=/home/mangoh/workspace/leaf-data/wp76stable/wp76-toolchain/sysroots/armv7a-neon-poky-linux-gnueabi -MMD -MF \_build\_helloCPP/wp76xx/component/b130cd0656327c8de99a44179d5831dc/obj/4c01286321aa8b611d1cea84c8618f67.o.d -c /home/mangoh/workspace/leaf-data/wp76stable/fx30-cat1-legato/apps/helloCPP/helloCPPComponent/helloCPP.cpp -o \_build\_helloCPP/wp76xx/component/b130cd0656327c8de99a44179d5831dc/obj/4c01286321aa8b611d1cea84c8618f67.o -DLE\_FILENAME=`basename /home/mangoh/workspace/leaf-data/wp76stable/fx30-cat1-legato/apps/helloCPP/helloCPPComponent/helloCPP.cpp` -Wall -fPIC -Werror -fvisibility=hidden -DMK\_TOOLS\_BUILD -DLEGATO\_EMBEDDED -I ./\_build\_helloCPP/wp76xx -I/home/mangoh/workspace/leaf-data/wp76stable/fx30-cat1-legato/interfaces -I/home/mangoh/workspace/leaf-data/wp76stable/fx30-cat1-legato/framework/include -I/home/mangoh/workspace/leaf-data/wp76stable/fx30-cat1-legato/apps/helloCPP -I./\_build\_helloCPP/wp76xx/component/b130cd0656327c8de99a44179d5831dc/src -DLE\_COMPONENT\_NAME=helloCPPComponent -DLE\_LOG\_SESSION=helloCPPComponent\_LogSession -DLE\_LOG\_LEVEL\_FILTER\_PTR=helloCPPComponent\_LogLevelFilterPtr “-DCOMPONENT\_INIT=LE\_CI\_LINKAGE LE\_SHARED void \_helloCPPComponent\_COMPONENT\_INIT()”  
> :0:16: error: ‘LE\_CI\_LINKAGE’ does not name a type; did you mean ‘LE\_FILENAME’?  
> /home/mangoh/workspace/leaf-data/wp76stable/fx30-cat1-legato/apps/helloCPP/helloCPPComponent/helloCPP.cpp:7:1: note: in expansion of macro ‘COMPONENT\_INIT’  
> COMPONENT\_INIT{  
> ^ ~~~~~~~~~~~~~  
> /home/mangoh/workspace/leaf-data/wp76stable/fx30-cat1-legato/apps/helloCPP/helloCPPComponent/helloCPP.cpp: In function ‘int greet()’:  
> /home/mangoh/workspace/leaf-data/wp76stable/fx30-cat1-legato/apps/helloCPP/helloCPPComponent/helloCPP.cpp:11:5: error: ambiguating new declaration of ‘int greet()’  
> int greet() {  
> ^ ~~~~  
> /home/mangoh/workspace/leaf-data/wp76stable/fx30-cat1-legato/apps/helloCPP/helloCPPComponent/helloCPP.cpp:5:6: note: old declaration ‘void greet()’  
> void greet(void);  
> ^ ~~~~  
> /home/mangoh/workspace/leaf-data/wp76stable/fx30-cat1-legato/apps/helloCPP/helloCPPComponent/helloCPP.cpp:14:1: error: no return statement in function returning non-void [-Werror=return-type]  
> }  
> ^  
> cc1plus: all warnings being treated as errors

```
#include <iostream>
using namespace std;

void greet(void);

COMPONENT_INIT{ 
    greet();
}

void greet() {
  cout << "Hello World!";
  return;
}

```

What am I doing wrong? Any help is greatly appreciated.

---

<div class="post-metadata">

### Author: ![jyijyi](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.legato.io/jyijyi/32/822_2.png) [@jyijyi](https://forum.legato.io/u/jyijyi)
#### Post date: [October 7, 2020, 2:23pm UTC](https://forum.legato.io/t/c-mkapp-problem-wp7607-1/5440/2 "2020-10-07T14:23:58Z")

</div>

you can refer to this one:(I can compile it in vscode)

> **[legato-af/apps/test/framework/c++ at master · legatoproject/legato-af](https://github.com/legatoproject/legato-af/tree/master/apps/test/framework/c%2B%2B)**
>
> master/apps/test/framework/c%2B%2B

[c++.rar](https://forum.legato.io/uploads/short-url/olN8djGGs13JM2u4unq9dVoI9sJ.rar) (1.2 KB)

---

<div class="post-metadata">

### Author: ![tadera](https://avatars.discourse-cdn.com/v4/letter/t/f14d63/32.png) [@tadera](https://forum.legato.io/u/tadera)
#### Post date: [October 8, 2020, 10:28am UTC](https://forum.legato.io/t/c-mkapp-problem-wp7607-1/5440/3 "2020-10-08T10:28:27Z")

</div>

The code you shared works, thanks.  
Is there a reason why “cout” doesn’t output anything though?

---

<div class="post-metadata">

### Author: ![jyijyi](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.legato.io/jyijyi/32/822_2.png) [@jyijyi](https://forum.legato.io/u/jyijyi)
#### Post date: [October 8, 2020, 10:44am UTC](https://forum.legato.io/t/c-mkapp-problem-wp7607-1/5440/4 "2020-10-08T10:44:23Z")

</div>

No idea, maybe you need to use “std::cout”

---

<div class="post-metadata">

### Author: ![tadera](https://avatars.discourse-cdn.com/v4/letter/t/f14d63/32.png) [@tadera](https://forum.legato.io/u/tadera)
#### Post date: [October 8, 2020, 10:45am UTC](https://forum.legato.io/t/c-mkapp-problem-wp7607-1/5440/5 "2020-10-08T10:45:02Z")

</div>

Already tried that but that’s not doing the trick.

---

<div class="post-metadata">

### Author: ![jyijyi](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.legato.io/jyijyi/32/822_2.png) [@jyijyi](https://forum.legato.io/u/jyijyi)
#### Post date: [October 8, 2020, 11:24am UTC](https://forum.legato.io/t/c-mkapp-problem-wp7607-1/5440/6 "2020-10-08T11:24:10Z")

</div>

What did you see in “logread”?

---

<div class="post-metadata">

### Author: ![tadera](https://avatars.discourse-cdn.com/v4/letter/t/f14d63/32.png) [@tadera](https://forum.legato.io/u/tadera)
#### Post date: [October 8, 2020, 11:31am UTC](https://forum.legato.io/t/c-mkapp-problem-wp7607-1/5440/7 "2020-10-08T11:31:18Z")

</div>

> Oct 8 13:29:50 swi-mdm9x28-wp user.info Legato: INFO | supervisor[830]/supervisor T=main | proc.c GetFaultAction() 323 | No fault action specified for process ‘helloCPP’. Assuming ‘ignore’.  
> Oct 8 13:29:50 swi-mdm9x28-wp user.warn Legato: -WRN- | supervisor[830]/supervisor T=main | proc.c GetWatchdogAction() 359 | helloCPP watchdogAction ‘’ in proc section  
> Oct 8 13:29:50 swi-mdm9x28-wp user.warn Legato: -WRN- | supervisor[830]/supervisor T=main | proc.c GetWatchdogAction() 359 | helloCPP watchdogAction ‘’ in proc section  
> Oct 8 13:29:50 swi-mdm9x28-wp user.info Legato: INFO | supervisor[830]/supervisor T=main | app.c app\_Start() 3420 | Starting app ‘helloCPP’  
> Oct 8 13:29:50 swi-mdm9x28-wp user.info Legato: INFO | supervisor[830]/supervisor T=main | app.c CreateFileLink() 2104 | Created file link ‘/dev/log’ to ‘/legato/systems/current/appsWriteable/helloCPP/dev/log’.  
> Oct 8 13:29:50 swi-mdm9x28-wp user.info Legato: INFO | supervisor[830]/supervisor T=main | app.c CreateFileLink() 2104 | Created file link ‘/dev/null’ to ‘/legato/systems/current/appsWriteable/helloCPP/dev/null’.  
> Oct 8 13:29:50 swi-mdm9x28-wp user.info Legato: INFO | supervisor[830]/supervisor T=main | app.c CreateFileLink() 2104 | Created file link ‘/dev/zero’ to ‘/legato/systems/current/appsWriteable/helloCPP/dev/zero’.  
> Oct 8 13:29:50 swi-mdm9x28-wp user.info Legato: INFO | supervisor[830]/supervisor T=main | app.c CreateFileLink() 2104 | Created file link ‘/legato/systems/current/lib/liblegato.so’ to ‘/legato/systems/current/appsWriteable/helloCPP/lib/liblegato.so’.  
> Oct 8 13:29:50 swi-mdm9x28-wp user.info Legato: INFO | supervisor[830]/supervisor T=main | app.c CreateFileLink() 2104 | Created file link ‘/lib/ld-linux.so.3’ to ‘/legato/systems/current/appsWriteable/helloCPP/lib/ld-linux.so.3’.  
> Oct 8 13:29:50 swi-mdm9x28-wp user.info Legato: INFO | supervisor[830]/supervisor T=main | app.c CreateFileLink() 2104 | Created file link ‘/lib/libc.so.6’ to ‘/legato/systems/current/appsWriteable/helloCPP/lib/libc.so.6’.  
> Oct 8 13:29:50 swi-mdm9x28-wp user.info Legato: INFO | supervisor[830]/supervisor T=main | app.c CreateFileLink() 2104 | Created file link ‘/lib/libpthread.so.0’ to ‘/legato/systems/current/appsWriteable/helloCPP/lib/libpthread.so.0’.  
> Oct 8 13:29:50 swi-mdm9x28-wp user.info Legato: INFO | supervisor[830]/supervisor T=main | app.c CreateFileLink() 2104 | Created file link ‘/lib/librt.so.1’ to ‘/legato/systems/current/appsWriteable/helloCPP/lib/librt.so.1’.  
> Oct 8 13:29:50 swi-mdm9x28-wp user.info Legato: INFO | supervisor[830]/supervisor T=main | app.c CreateFileLink() 2104 | Created file link ‘/lib/libdl.so.2’ to ‘/legato/systems/current/appsWriteable/helloCPP/lib/libdl.so.2’.  
> Oct 8 13:29:50 swi-mdm9x28-wp user.info Legato: INFO | supervisor[830]/supervisor T=main | app.c CreateFileLink() 2104 | Created file link ‘/lib/libgcc\_s.so.1’ to ‘/legato/systems/current/appsWriteable/helloCPP/lib/libgcc\_s.so.1’.  
> Oct 8 13:29:50 swi-mdm9x28-wp user.info Legato: INFO | supervisor[830]/supervisor T=main | app.c CreateFileLink() 2104 | Created file link ‘/lib/libm.so.6’ to ‘/legato/systems/current/appsWriteable/helloCPP/lib/libm.so.6’.  
> Oct 8 13:29:50 swi-mdm9x28-wp user.info Legato: INFO | supervisor[830]/supervisor T=main | app.c CreateFileLink() 2104 | Created file link ‘/usr/lib/libstdc++.so.6’ to ‘/legato/systems/current/appsWriteable/helloCPP/lib/libstdc++.so.6’.  
> Oct 8 13:29:50 swi-mdm9x28-wp user.info Legato: INFO | supervisor[830]/supervisor T=main | app.c CreateFileLink() 2104 | Created file link ‘/legato/systems/current/apps/helloCPP/read-only/lib/libComponent\_helloCPPComponent.so’ to '/legato/systems/current/appsWriteable/hello  
> Oct 8 13:29:50 swi-mdm9x28-wp user.info Legato: INFO | supervisor[830]/supervisor T=main | app.c CreateFileLink() 2104 | Created file link ‘/legato/systems/current/apps/helloCPP/read-only/bin/helloCPP’ to ‘/legato/systems/current/appsWriteable/helloCPP/bin/helloCPP’.  
> Oct 8 13:29:50 swi-mdm9x28-wp user.info Legato: INFO | supervisor[830]/supervisor T=main | app.c CreateTmpFs() 1738 | Mounted tmpfs at /legato/systems/current/appsWriteable/helloCPP/tmp.  
> Oct 8 13:29:50 swi-mdm9x28-wp user.info Legato: INFO | supervisor[830]/supervisor T=main | app.c CreateFileLink() 2104 | Created file link ‘/tmp/legato/serviceDirectoryServer’ to ‘/legato/systems/current/appsWriteable/helloCPP/tmp/legato/serviceDirectoryServer’.  
> Oct 8 13:29:50 swi-mdm9x28-wp user.info Legato: INFO | supervisor[830]/supervisor T=main | app.c CreateFileLink() 2104 | Created file link ‘/tmp/legato/serviceDirectoryClient’ to ‘/legato/systems/current/appsWriteable/helloCPP/tmp/legato/serviceDirectoryClient’.  
> Oct 8 13:29:50 swi-mdm9x28-wp user.info Legato: INFO | supervisor[830]/supervisor T=main | resourceLimits.c SetRLimitValue() 282 | Setting resource limit maxCoreDumpFileBytes to value 102400.  
> Oct 8 13:29:50 swi-mdm9x28-wp user.info Legato: INFO | supervisor[830]/supervisor T=main | resourceLimits.c SetRLimitValue() 282 | Setting resource limit maxFileBytes to value 102400.  
> Oct 8 13:29:50 swi-mdm9x28-wp user.info Legato: INFO | supervisor[830]/supervisor T=main | resourceLimits.c SetRLimitValue() 282 | Setting resource limit maxLockedMemoryBytes to value 8192.  
> Oct 8 13:29:50 swi-mdm9x28-wp user.info Legato: INFO | supervisor[830]/supervisor T=main | resourceLimits.c SetRLimitValue() 282 | Setting resource limit maxFileDescriptors to value 256.  
> Oct 8 13:29:50 swi-mdm9x28-wp user.info Legato: INFO | supervisor[830]/supervisor T=main | resourceLimits.c SetRLimitValue() 282 | Setting resource limit maxMQueueBytes to value 512.  
> Oct 8 13:29:50 swi-mdm9x28-wp user.info Legato: INFO | supervisor[830]/supervisor T=main | resourceLimits.c SetRLimitValue() 282 | Setting resource limit maxThreads to value 20.  
> Oct 8 13:29:50 swi-mdm9x28-wp user.info Legato: INFO | supervisor[830]/supervisor T=main | resourceLimits.c SetRLimitValue() 282 | Setting resource limit maxQueuedSignals to value 100.  
> Oct 8 13:29:50 swi-mdm9x28-wp user.info Legato: INFO | supervisor[830]/supervisor T=main | proc.c proc\_Start() 1390 | Starting process ‘helloCPP’ with pid 31341  
> Oct 8 13:29:50 swi-mdm9x28-wp user.info Legato: INFO | supervisor[31341]/supervisor T=main | proc.c proc\_Start() 1355 | Execing ‘helloCPP’  
> Oct 8 13:29:50 swi-mdm9x28-wp user.notice kernel: [15517.913227] audit: type=1400 audit(1602156590.639:42): lsm=SMACK fn=smack\_inode\_getattr action=denied subject=“app.helloCPP” object=“admin” requested=r pid=31341 comm=“helloCPP” path=“pipe:[93796]” dev=“pipefs” ino=93796

---

<div class="post-metadata">

### Author: ![jyijyi](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.legato.io/jyijyi/32/822_2.png) [@jyijyi](https://forum.legato.io/u/jyijyi)
#### Post date: [October 9, 2020, 1:48am UTC](https://forum.legato.io/t/c-mkapp-problem-wp7607-1/5440/8 "2020-10-09T01:48:04Z")

</div>

I can see "std::cout " can print out the log in logread.  
I add the following:

* * *

std::cout \<\< "stuff: ";

* * *

I can see it in the logread:

Jan 6 00:15:51 fx30 user.info Legato: INFO | supervisor[3613]/supervisor T=main | proc.c proc\_Start() 1354 | Execing ‘helloCpp’  
Jan 6 00:15:51 fx30 user.info Legato: INFO | helloCpp[3613]/cppComponent T=main | Hello.cpp \_cppComponent\_COMPONENT\_INIT() 16 | Hello world, from thread 1.  
Jan 6 00:15:51 fx30 user.info Legato: INFO | helloCpp[3613]/cppComponent T=main | Hello.cpp \_cppComponent\_COMPONENT\_INIT() 30 | Thead 2 stared, and waiting for it to complete.  
Jan 6 00:15:51 fx30 user.info Legato: INFO | helloCpp[3613]/cppComponent T=thread 2 | Hello.cpp operator()() 25 | Hello world, from thread 2.  
Jan 6 00:15:51 fx30 user.info Legato: INFO | helloCpp[3613]/cppComponent T=main | Hello.cpp \_cppComponent\_COMPONENT\_INIT() 33 | Thead 2 ended, all done with init.  
Jan 6 00:15:51 fx30 user.info Legato: INFO | helloCpp[3613] | stuff:
