Issues in Linking component with Application

Hi,

I am facing multiple issues with Legato Application Framework.

Issue 1. I have created a component named “myLib” and add one header file to it named “ApiInterface.h”

While building this component I am getting following error:

/home/warlord/legato/workspace/myLib/Component.cdef:4:0: error: Couldn’t find source file ‘_componentMain.c’
make: Leaving directory `/home/warlord/legato/workspace/myLib/Target_Legato_Debug’

Issue 2. I have created a Legato Application named “myApp”. I added “ApiInterface.h” from “myLib” to myAppComponent.c but I am getting Unresolved Inculsion error here.

Issue 3. I also want to include to my application but here also I am getting Unresolved Inculsion error.

I have attached the screenshot of my project structure here. Please help me resolve these issues.

Thanks,
Yogesh

Hi @yogesh.tyagi

It’s easier to work with nested components, instead of component projects.
(Unless you want to share a component code with someone else, using component projects is not a good idea)

The other aspect is that the usual Legato way for components talking together is to define a .api file to describe the interface (API Files - Legato Docs)
The advantage is that you define a language-agnostic interface, potentially usable by other components implemented in other languages.
Another advantage is that you decouple the interface and the implementation. The interface consumer virtually doesn’t care who is implementing the interface, and it’s easy to bind to alternative implementations without impacting the interface client.
The drawback is that .api interfaces are restricted to a set of features common to various languages.

If you want to stick to a traditional C interface, you’ll need to specify where are located the interfaces and libs, by using the cflags section of the component.cdef file, to use gcc options for include paths and linked libs.

Hope this will help.

Thanks @daav for detailed explanation. But if we have a team of multiple people working on a project, would you advice to break the project into multiple nested components or should we create multiple component projects.

If I create nested component, how will I share this component with other people who need the functionality of this nested component?

Thanks,
Yogesh

Hi @yogesh.tyagi

Unless you plan to share the code on different source code repositories, because some of your teammates shouldn’t see the code of other teammates, it’s easier to have one app project with nested components, shared with everyone.

Concerning your other question, please clarify:

  • do you want to share with people external to your organization (community)?
  • do you want to share your code (open-source) or share your stuff in compiled format (because you want to preserve some of your intellectual property)?

Hi @daav,

I don’t have to share with people external to my organization. I am going to share with my internal team who will be developing the app plus other components of this project. I don’t mind sharing the code with them.

In my earlier project, I used to share with them the library( .so file developed in c language) along with the interface file (.h file having apis exposed to them which is implemented by my library). How do I achieve the same thing in Legato?

I am fine with either of the above two approached but I am keen to learn Legato way of developing and sharing components since it’s a new and easy way of developing a complex system, it seems.

What will be your suggestion in this scenario?

Thanks,
Yogesh

Hi @yogesh.tyagi

if everything is internal, and unless you have a good reason to want keeping a “staged build” architecture (I mean you deliver a built lib, that is an input for other people), my suggestion would be to have a standalone app project with nested components below.
Legato build system takes care of building all the components when you’ll build the main app.
It’s just more complex to setup an architecture where the app depends on prebuilt stuff.

Thanks @daav. Just few more queries here.

  1. How will my App interact with the nested component? Is it same as two components interact with each other?

  2. How will I share my nested component with other other team members?

  3. Interface protocol takes no arguments and returns nothing, so how will components pass data to each other?

Thanks,
Yogesh

Hi @yogesh.tyagi

To answer to your questions:

  1. There is no code at application level. In Legato apps, all the code is written in components. Applications are just containers that allow to run processes.

  2. Recommendation would be that all developers share the same code base. Some of them work on some components, some other on other components. And everybody is able to build the app.

  3. If you look at the basic example (http://legato.io/legato-docs/latest/basicAppsIPC.html), it’s true that the given one is pretty simple.
    But please have look on the API files syntax: Syntax - Legato Docs
    You’ll see that it’s obviously possible to handle parameters and return values.
    You can have a look at framework interfaces for some examples: legato-af/interfaces at master · legatoproject/legato-af · GitHub