New Yocto build to add a library


#1

Hello,

I’ve been trying to include a 3rd party library(libcurl) to my DS project for mangOH without success.
Is it possible that in order to include the library I need to make a new build for the Yocto including it? In that case do you have an example or a guide on how to do it?
If that’s not the way to do it could you please tell me how it’s done?

Thank you,

Pau


#2

The curl package that includes libcurl is already part of the yocto-1.7 build for MangOH boards:
$ bitbake-layers show-recipes curl
Parsing recipes…done.
=== Available recipes matching curl: ===
curl:
meta 7.37.1

This gets built and installed on the MangOH board by default:
root@swi-mdm9x15:~# which curl
/usr/bin/curl
root@swi-mdm9x15:~# ls /usr/lib/curl
/usr/lib/libcurl.so.5 /usr/lib/libcurl.so.5.3.0

If you are looking for a custom curl library/package, you can add its recipe to the Yocto build. For this procedure, it is best to follow the instructions on the Yocto site: wiki.yoctoproject.org/wiki/How_ … o_Yocto.3F


#3

Hello,

Thanks for your answer. I’ve tried what you told me and i noticed that i didn’t have the last version of the mangOH software, i had 16.01Beta.
I updated it to 16.04 and the Ubuntu VM too.

Now I’ve the libcurl on the board, but can’t include it to my DS project. Can you help me with that?


#4

Hi,

Indeed it looks like the libcurl is not available in the toolchain. We’ll have a look at this to fix that ASAP.
In the meantime, here is a workaround.

First of all, you’ll need *.so files (libcurl + dependencies) to provide to the linker, and header files to be included in your code.
It is possible to directly grab the so files from the device, and the header files from the curl website (curl.haxx.se/download.html)
I’ve done it for you in the attached archive ([color=#FF0000]Caution: I’ve named it .zip to workaround the forum filter, but this is a .tar.xz file; please rename it before usage[/color])
[attachment=2]libcurl.zip[/attachment]

I suggest you to extract the content of the file to a libcurl sub-directory of your application project.
Then, you’ll need to update your app settings.

In Project properties > C/C++ Build > Settings > mkapp Tool > C build options > Additional Linker Options area, add the following options:
[ul]
[li]-Wl,-rpath={ProjDirPath}/libcurl[/li] [li]-L{ProjDirPath}/libcurl[/li]
[li]-l:libcurl.so.5[/li][/ul]
This should look like this:
[attachment=1]props.png[/attachment]

Then, in Project properties > Legato application > API directories, add a workspace path and point to your libcurl/include directory:
[attachment=0]include.png[/attachment]

Then, we need to configure the bindings to import the libs inside the sandbox at runtime; I’ve done it in the Component.cdef file:


sources:
{
	testWithCurl.c
}

requires: {
	file: {
		/usr/lib/libcurl.so.5		/lib/
		/usr/lib/libgmp.so.10		/lib/
		/usr/lib/libgnutls.so.28		/lib/
		/usr/lib/libhogweed.so.2	/lib/
		/usr/lib/libnettle.so.4		/lib/
		/lib/libz.so.1			/lib/
	}
}

Now the app should build.
To test it, I’ve written that code:

#include "legato.h"
#include "curl.h"

COMPONENT_INIT
{
    LE_INFO("curl try: %s", curl_version());
}

And then I’m getting this in the logs:

Jan  6 01:06:42 | Legato | testwithcurl[17135]/testWithCurlComponent T=main | testWithCurl.c _testWithCurlComponent_COMPONENT_INIT() 6 | curl try: libcurl/7.37.1 GnuTLS/3.3.5 zlib/1.2.8

Hope this will help.