Ways to provide additional headers for building application through command line and makefile

Hi, I am very new to legato-based development, I have started off just a week ago.

Existing system:

  • I have installed legato17-08.1 on my host (linux - ubuntu16.04 LTS) computer, used a zip, did not clone.

  • I have installed latest toolchain (Release 14) from sierra wireless.

  • I have installed legato application developer studio version 5.2.

  • I have a mangOH Green board with me, it has a WP8548 chip on it and I have tested it with helloWorld program that I built and deployed on the device using legato application developer studio version 5.2.

  • I am aware of the process of running ‘bin/legs’ every time I open a terminal for supporting commands related to legato.

  • I have set the environment variable LEGATO_ROOT to the directory where I have installed legato-17.08.1. I have not set CURDIR yet. Though Environment Variables section clearly states that mk tools will create CURDIR and some other environment variables.

Problem Statement:
I want to add a header file located in a different directory than where the application is being built. When I invoke the make wp85 command, I get an error stating that the referred header could not be found (Not the exact words),

fatal error: project/commons.h: No such file or directory

This header is included in one of the .hh files.

What I have tried:
Based on description for cflags I tried

cflags:
{
     -I~/project/commons.h
}

I have also tried using -s option with mkapp command, but it didn’t work.

What is the way to provide additional header files?

1 Like

Hi @wedapashi,

you’re pretty close, I would say that ~ doesn’t work as it is something that is just interpreted by the shell, not mktools.

Another thing is that you need to specify the directory.

So

cflags:
{
     -I${HOME}/project/
}

and

#include "common.sh"
1 Like

@CoRfr: Thanks for responding. I have tried what you suggested.

    cflags:
    {
           -I/home/wedapashi/mangoh_g/workspace/project/
    }

And have a #include “commons.h” in a .hh file.

But it still generates an error that it can not locate commons.h.
I have checked file names and path word by word.

Hi @wedapashi,

Try without specifying the file name, rather just the directory where the file resides as @CoRfr suggested.

Also, make sure to add the colon : after cflags like so:

cflags:
{
    -I/home/wedapashi/mangoh_g/workspace/project/
}
1 Like

@raf: Kindly accept my apologies for a mere copy+paste from one of my source files, Please see the edit. I have not specified the file under cflags section in .cdef file. Thanks for the heads-up about missing the colon :, fortunately, its there in the actual .cdef file.

Additionally: I tried a horrible idea like putting the whole directory which I am trying to get headers files to make it work, it works that way, but I have to look at all the #includes in all the files and change them accordingly. I don’t think thats the way going ahead.

@wedapashi. Not a problem. Yeah, I agree. There’s got to be a better way.

I noticed you mentioned a .hh - I take it you’re trying to compile a C++ program?

If so, perhaps trying using cxxflags: instead.

1 Like

Thanks a ton. cxxflags: worked! @raf, @CoRfr.
I should (at least now) start looking at the documentation carefully.

Great! Glad to hear you got it working @wedapashi

1 Like