How to use libcurl from legato?


#1

Hello,

I a have written a test app to POST data to my server from an FX30S.

It fails to build. Below is the output.

mark@ubuntu:~/workspace/aimInterface$ mkapp -t wp85 aimInterface.adef
[1/1] Regenerating build script
[6/8] Linking C executable
FAILED: /opt/swi/y17-ext/sysroots/x86_64-pokysdk-linux/usr/bin/arm-poky-linux-gnueabi/arm-poky-linux-gnueabi-gcc --sysroot=/opt/swi/y17-ext/sysroots/armv7a-vfp-neon-poky-linux-gnueabi -o _build_aimInterface/wp85/app/aimInterface/staging/read-only/bin/aimInterface _build_aimInterface/wp85/app/aimInterface/obj/aimInterface/_main.c.o -rdynamic -Wl,–enable-new-dtags,-rpath="$ORIGIN/…/lib" -L_build_aimInterface/wp85/staging/read-only/lib “-L_build_aimInterface/wp85/staging/read-only/lib” -lComponent_aimInterfaceComponent “-L_build_aimInterface/wp85/staging/read-only/lib” -lComponent_aimInterfaceComponent “-L$LEGATO_BUILD/framework/lib” -llegato -lpthread -lrt -ldl -lm
_build_aimInterface/wp85/staging/read-only/lib/libComponent_aimInterfaceComponent.so: undefined reference to curl_easy_perform' _build_aimInterface/wp85/staging/read-only/lib/libComponent_aimInterfaceComponent.so: undefined reference tocurl_easy_init’
_build_aimInterface/wp85/staging/read-only/lib/libComponent_aimInterfaceComponent.so: undefined reference to curl_easy_strerror' _build_aimInterface/wp85/staging/read-only/lib/libComponent_aimInterfaceComponent.so: undefined reference tocurl_version’
_build_aimInterface/wp85/staging/read-only/lib/libComponent_aimInterfaceComponent.so: undefined reference to curl_easy_setopt' _build_aimInterface/wp85/staging/read-only/lib/libComponent_aimInterfaceComponent.so: undefined reference tocurl_easy_cleanup’
collect2: error: ld returned 1 exit status
ninja: build stopped: subcommand failed.

I found some references that seemed to indicate that there needed to be a “file” section in the “requires:” section of the Component.cdef for the libraries:

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/
}

but that didn’t help.

What piece of magic am I missing?

Thanks,
Mark


#2

Try adding

lib:
{
    curl
}  

to your .cdef, and then in your .c files make sure you #include <curl/curl.h>
Let me know if you still have any trouble. It might be worth opening the httpget example app to compare.


#3

It is also worth nothing that you should have:

file:
{
    /usr/lib/xxx        /usr/lib/
}

instead of

file:
{
    /usr/lib/xxx        /lib/
}

#4

Thank you. That was the piece I was missing.

Mark