How to create a Legato Application Project with C++ Source Files

Hi All,
I have created a application on Legato 16.7 and wish to include the Open source C++ library in my legato application.

Can I include and use api’s from this library in my existing Legato application which is using c source file as per the standard option in DS.

I think to include the headers and use the C++ open source library it will better to have the legato application in source in C++ file.Can I do that with in the Legato Application in DS default option with c source file?

Can someone help with creating a Legato Application with C++ or what is the best way to go about this task.Need some urgent help as I am struck at this task.

Regards
Suruchi

Hi,

you can add C++ code in your Legato app by simply using *.cpp files in your component(s). They will be automatically compiled as C++ sources, and considered as such by DS.
When you need to call C stuff from C++ files, you’ll just need to surround the code by an extern “C” block:

extern "C" {

#include "legato.h"
    
COMPONENT_INIT
{
    LE_INFO("Hello, world.");
}

// extern "C"
}

Thank you for your response ! I got some idea how to go abt it. I will try this.