C++ mkapp problem - WP7607-1

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.

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

c++.rar (1.2 KB)

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

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

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

What did you see in “logread”?

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

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: