# Compile 3rd library (libcurl, etc ...) for Legato

**URL:** <https://forum.legato.io/t/compile-3rd-library-libcurl-etc-for-legato/241>\
**Category:** Legato Application Framework\
**Created:** [July 11, 2016, 1:22pm UTC](https://forum.legato.io/t/compile-3rd-library-libcurl-etc-for-legato/241 "2016-07-11T13:22:25Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![trnguyen](https://avatars.discourse-cdn.com/v4/letter/t/5fc32e/32.png) [@trnguyen](https://forum.legato.io/u/trnguyen)\
**Post date:** [July 11, 2016, 1:22pm UTC](https://forum.legato.io/t/compile-3rd-library-libcurl-etc-for-legato/241/1 "2016-07-11T13:22:25Z")

</div>

Hi all,

I’m new to Legato.  
I have been working on some embedded Linux device before.  
I have an C application which linked to libcurl library on my current device and I want to make it run on Legato platform.  
So is it possible to compile libcurl (or any 3rd C/C++ library in general) as a Legato component and my application as a Legato application then install and run it on my MangOH dev board? I would really appreciate if you have any tutorial related to this subject.

I’m using Developer Studio 4.1 (Legato 16.4) on Ubuntu 16.04 64 bits.

Thank a lot for your help,

---

<div class="post-metadata">

**Author:** ![gregnietsky](https://avatars.discourse-cdn.com/v4/letter/g/7feea3/32.png) [@gregnietsky](https://forum.legato.io/u/gregnietsky)\
**Post date:** [July 11, 2016, 5:23pm UTC](https://forum.legato.io/t/compile-3rd-library-libcurl-etc-for-legato/241/2 "2016-07-11T17:23:02Z")

</div>

Yes it can be done busy doing just that to include linphone for SIP VOIP …

i build the package then install it into the sysroot and put the bits i want into a folder that i include in the adef.

i even added a driver framework for legato audio in the legacy package … one of the packages i added was sqlite3.

Greg

---

<div class="post-metadata">

**Author:** ![trnguyen](https://avatars.discourse-cdn.com/v4/letter/t/5fc32e/32.png) [@trnguyen](https://forum.legato.io/u/trnguyen)\
**Post date:** [July 12, 2016, 9:04am UTC](https://forum.legato.io/t/compile-3rd-library-libcurl-etc-for-legato/241/3 "2016-07-12T09:04:16Z")

</div>

Hi Greg,

Thank you for your response. Could you be a little more specific about how doing it?  
I’m trying to doing it with Developper Studio by importing libcurl as a C/C++ project from Existing source.  
Then I choose Legato Application Framwork GCC as toolchain and Legato Application Framwork Builder as builder but the project couldn’t be built.

Regards,

Trung

---

<div class="post-metadata">

**Author:** ![gregnietsky](https://avatars.discourse-cdn.com/v4/letter/g/7feea3/32.png) [@gregnietsky](https://forum.legato.io/u/gregnietsky)\
**Post date:** [July 12, 2016, 7:57pm UTC](https://forum.legato.io/t/compile-3rd-library-libcurl-etc-for-legato/241/4 "2016-07-12T19:57:50Z")

</div>

You using linux or similar ?? i do it writing a make file from the console but it does work from the IDE [tested it for you] using linux as a dev platform helps as you can run the shell scripts.

---

<div class="post-metadata">

**Author:** ![daav](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.legato.io/daav/32/64_2.png) [@daav](https://forum.legato.io/u/daav)\
**Post date:** [July 13, 2016, 6:45am UTC](https://forum.legato.io/t/compile-3rd-library-libcurl-etc-for-legato/241/5 "2016-07-13T06:45:13Z")

</div>

> [@trnguyen](#):
>
> Then I choose Legato Application Framwork GCC as toolchain and Legato Application Framwork Builder as builder but the project couldn’t be built.

When you want to build a non-legato project in DS, you need to choose Legato Linux GCC toolchain, and Make builder (Legato) as builder, to get something working.

---

<div class="post-metadata">

**Author:** ![gregnietsky](https://avatars.discourse-cdn.com/v4/letter/g/7feea3/32.png) [@gregnietsky](https://forum.legato.io/u/gregnietsky)\
**Post date:** [July 14, 2016, 8:33am UTC](https://forum.legato.io/t/compile-3rd-library-libcurl-etc-for-legato/241/6 "2016-07-14T08:33:53Z")

</div>

## Makefile bits this is abuse of makefile but you will get some ideas how to do it

PREFIX=/usr

LEGATO\_OUTPUT = \_build\_linphone/wp85/build  
TARGET = wp85  
TOOLCHAINPRE = ${WP85\_TOOLCHAIN\_DIR}/arm-poky-linux-gnueabi

SYSROOT = $(shell $(TOOLCHAINPRE)-gcc -print-sysroot)  
PWD = $(shell pwd)

CC = $(TOOLCHAINPRE)-gcc  
CXX = $(TOOLCHAINPRE)-g++  
LD = $(TOOLCHAINPRE)-ld  
AR = $(TOOLCHAINPRE)-ar  
RANLIB = $(TOOLCHAINPRE)-ranlib

sqlite-autoconf\_OPT = CFLAGS=“-DSQLITE\_SECURE\_DELETE -DSQLITE\_ENABLE\_UNLOCK\_NOTIFY”

sqlite-autoconf:  
(if [! -d build/$@];then   
mkdir build/$@;   
fi;  
cd $@;   
./$($@\_CPTH)configure --prefix=/usr --libdir=/usr/lib CC=$(CC) CXX=$(CXX) --host=arm-poky-linux-gnueabi $($@\_OPT))  
make -C $@  
make -C $@ DESTDIR=$(SYSROOT) install  
make -C $@ DESTDIR=$(PWD)/output install

install:  
mkdir -p $(LEGATO\_OUTPUT)  
(cd output && rsync -avPR --exclude=_.a --exclude=_.la usr/lib usr/bin usr/sbin ../$(LEGATO\_OUTPUT)/)  
$(TOOLCHAINPRE)-strip $(LEGATO\_OUTPUT)/usr/bin/\* || true  
$(TOOLCHAINPRE)-strip $(LEGATO\_OUTPUT)/usr/sbin/\* || true  
$(TOOLCHAINPRE)-strip $(LEGATO\_OUTPUT)/usr/lib/\* || true  
./mkadef \> linphone.adef  
mkapp -t $(TARGET) linphone.adef

---

<div class="post-metadata">

**Author:** ![trnguyen](https://avatars.discourse-cdn.com/v4/letter/t/5fc32e/32.png) [@trnguyen](https://forum.legato.io/u/trnguyen)\
**Post date:** [July 20, 2016, 4:02pm UTC](https://forum.legato.io/t/compile-3rd-library-libcurl-etc-for-legato/241/7 "2016-07-20T16:02:07Z")

</div>

Hi everyone,

Please forgive me for taking so long to reply, I just came back from vacation yesterday.

[quote=“daav”]  
When you want to build a non-legato project in DS, you need to choose Legato Linux GCC toolchain, and Make builder (Legato) as builder, to get something working.[/quote]

Thank you it is working, well I have to do a manual configure to create a right Makefile but everything seems good. I can complie curl, json-c, …, copy them manually and make them run successfully in my MangOH board.

## [quote=“gregnietsky”]Makefile bits this is abuse of makefile but you will get some ideas how to do it

PREFIX=/usr

LEGATO\_OUTPUT = \_build\_linphone/wp85/build  
TARGET = wp85  
TOOLCHAINPRE = ${WP85\_TOOLCHAIN\_DIR}/arm-poky-linux-gnueabi

SYSROOT = $(shell $(TOOLCHAINPRE)-gcc -print-sysroot)  
PWD = $(shell pwd)

CC = $(TOOLCHAINPRE)-gcc  
CXX = $(TOOLCHAINPRE)-g++  
LD = $(TOOLCHAINPRE)-ld  
AR = $(TOOLCHAINPRE)-ar  
RANLIB = $(TOOLCHAINPRE)-ranlib

sqlite-autoconf\_OPT = CFLAGS=“-DSQLITE\_SECURE\_DELETE -DSQLITE\_ENABLE\_UNLOCK\_NOTIFY”

sqlite-autoconf:  
(if [! -d build/$@];then   
mkdir build/$@;   
fi;  
cd $@;   
./$($@\_CPTH)configure --prefix=/usr --libdir=/usr/lib CC=$(CC) CXX=$(CXX) --host=arm-poky-linux-gnueabi $($@\_OPT))  
make -C $@  
make -C $@ DESTDIR=$(SYSROOT) install  
make -C $@ DESTDIR=$(PWD)/output install

install:  
mkdir -p $(LEGATO\_OUTPUT)  
(cd output && rsync -avPR --exclude=_.a --exclude=_.la usr/lib usr/bin usr/sbin ../$(LEGATO\_OUTPUT)/)  
$(TOOLCHAINPRE)-strip $(LEGATO\_OUTPUT)/usr/bin/\* || true  
$(TOOLCHAINPRE)-strip $(LEGATO\_OUTPUT)/usr/sbin/\* || true  
$(TOOLCHAINPRE)-strip $(LEGATO\_OUTPUT)/usr/lib/\* || true  
./mkadef \> linphone.adef  
mkapp -t $(TARGET) linphone.adef[/quote]

Your Makefile seems good, that might be what I need to create a packaging .update for each library/app and install it in Legato platform. I’ll keep you informed about my tests.
