Issue while linking jansson shared library

Hi, I am trying a sample application for connecting mangOH Green to Google Cloud.
After spending some time for porting the example as per updated libraries on which the application depends, I am facing an issue with linking a shared library called libjansson.

I referred the documentation and procedure to compile and install the Jansson library from the Getting Started page on their website.

In my Component.cdef, I have:

    -ljansson -ljwt -lcrypto -L/usr/local/lib

Problem statement:
When I build the code, I get following error.

/usr/local/lib/ file not recognized: File format not recognized

My interpretation of the issue is, is the problem with not cross-compiling libjansson? I have compiled Jansson straight and simple, do I have to build it with any considerations for legato?
The documentation for Jansson has a CMake section, which says,

By default the CMake project will generate build files for building the static library. To build the shared version use: cmake -DJANSSON_BUILD_SHARED_LIBS=1

I have done this step.
Is there anything else specific to legato?

What I have tried:
To know if the Jansson is properly installed or not, I wrote a simple ‘Hello World’ program in C and it had a

#include <jansson.h>

and was build using

gcc -o HelloWorld hello.c -ljansson

And, it did not report any linker errors related to Jansson (or

Additional details if required:

Existing system:

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

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

  3. I have installed legato application developer studio version 5.2.

  4. 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.

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

  6. I have been able to build (on command line) sample applications provided by legato.

It looks like the build system is picking up some lib from your system.

How are you building Legato? make wp85?

What about your app?

@CoRfr: Thanks for responding.

I am absolutely sure that the application I am trying to build uses Jansson library by means of a .so file, To support this, I have already compiled and installed the Jansson library and I can see the files that have been put under /usr/local/lib/ directory.

Its just that I am unable to understand why the linker is unable to understand the file format, while gcc does seem to have no issues.

To answer your question regarding how I build legato, Yes I used wp85 to build legato, The application I am trying to work with, is being built with make wp85.

Cross-compiled libraries should be in a path such as /usr/local/ on your host, since this is really meant for files with the same architecture as your host (x86-64 for instance).

Instead you should rely on something like externalBuild to provide a Component.cdef that just ‘represents’ jansson from a Legato point of view.

That way Legato knows how to compile it and can take care of cross-compiling it for you.

Jansson is a bit of a particular case since the source code is already in Legato, and it is build as a dependency to some framework tools, so you can do something like -L${LEGATO_BUILD}/framework/libjansson/lib/ -ljansson for ldflags and -I${LEGATO_BUILD}/framework/libjansson/include for cflags.

1 Like

Thanks. With your inputs, I have managed to resolve the issues related to

Another question: Can an external library cross-compile another external library using externalBuild? And, eventually both of them will be used in my application. In short, can a Component.cdef, (placed in the directory which contains the source for an external library) having an externalBuild section, also contain a required section with component?

Glad you were able to solve your build issue.

As for your question, I think that yes externalBuild and required: components: are not mutually exclusive, so it should work.

I am trying to link an external .so file of postgresql to my application and havent been able to do it yet.

i am trying the external build method by creating a component ( through the option of creating a legato component in the IDE) in the directory of my library. When I build this component through the IDE , it gives an error: Legato builder: ** ERROR: Couldn’t find component ‘lala’.

And so , linking it to my application gives the same errors.

This might be a rudimentary issue but i am stuck!! It be great if you could help me.

How do I proceed or where am I wrong?

My .CDEF file for the component is this :

{ /home/liberator/amillib // this is where I have stored my .so files


“${CURDIR}/configure --target=$${2.2.3.SWI9X07Y_02160200-wp76xx-native-x86_64-201805030754%-}”