Running Azure IoT sdk-c

Hi all, does anyone has experience on how to link source files in the component def to run the Azure IoT sdk-c?

Is that you must run in legato application?

I have tried to compile the azure sdk with wp76 toolchain, but not in legato app, i guess you need to put the source file one by one.

do you have a list of all the sources which need to be included to run this sdk-c on the legato?

No, i don’t have …

would you have the list of sources you have added to the project for compiling?

no, i don’t have…
do you try to compile with toolchain ( not in legato application) and see if it can be run first?

so you mean compiling the sdk-c library and then to run the binary on the target?

correct, that is what i did in the past.

and then you linked the external .so library to the legato app you built?
How did you specify to use the legato toolchain when making the azure-sdk?
Or you just ran the make and then tested it on the target.

just make and test the binary in target.
nothing related to legato

i am trying to port the sdk into the legato, but I am wondering how I can include external libraries?

I am getting this errors:
SSL_get_error' _build_mqttClientAzure/wp77xx/staging/read-only/lib/libComponent_mqttClientAzureComponent.so: undefined reference to ENGINE_free’
_build_mqttClientAzure/wp77xx/staging/read-only/lib/libComponent_mqttClientAzureComponent.so: undefined reference to SSL_write' _build_mqttClientAzure/wp77xx/staging/read-only/lib/libComponent_mqttClientAzureComponent.so: undefined reference to X509_VERIFY_PARAM_set_hostflags’
_build_mqttClientAzure/wp77xx/staging/read-only/lib/libComponent_mqttClientAzureComponent.so: undefined reference to ERR_remove_thread_state' _build_mqttClientAzure/wp77xx/staging/read-only/lib/libComponent_mqttClientAzureComponent.so: undefined reference to SSL_free’
_build_mqttClientAzure/wp77xx/staging/read-only/lib/libComponent_mqttClientAzureComponent.so: undefined reference to CRYPTO_cleanup_all_ex_data' _build_mqttClientAzure/wp77xx/staging/read-only/lib/libComponent_mqttClientAzureComponent.so: undefined reference to uuid_unparse’
_build_mqttClientAzure/wp77xx/staging/read-only/lib/libComponent_mqttClientAzureComponent.so: undefined reference to SSL_CTX_set_verify' _build_mqttClientAzure/wp77xx/staging/read-only/lib/libComponent_mqttClientAzureComponent.so: undefined reference to BIO_read’
_build_mqttClientAzure/wp77xx/staging/read-only/lib/libComponent_mqttClientAzureComponent.so: undefined reference to CRYPTO_set_dynlock_lock_callback' _build_mqttClientAzure/wp77xx/staging/read-only/lib/libComponent_mqttClientAzureComponent.so: undefined reference to X509_VERIFY_PARAM_set1_host’
_build_mqttClientAzure/wp77xx/staging/read-only/lib/libComponent_mqttClientAzureComponent.so: undefined reference to CRYPTO_num_locks' _build_mqttClientAzure/wp77xx/staging/read-only/lib/libComponent_mqttClientAzureComponent.so: undefined reference to SSL_CTX_set_cert_verify_callback’
_build_mqttClientAzure/wp77xx/staging/read-only/lib/libComponent_mqttClientAzureComponent.so: undefined reference to SSL_library_init' _build_mqttClientAzure/wp77xx/staging/read-only/lib/libComponent_mqttClientAzureComponent.so: undefined reference to SSL_read’
_build_mqttClientAzure/wp77xx/staging/read-only/lib/libComponent_mqttClientAzureComponent.so: undefined reference to SSL_new' _build_mqttClientAzure/wp77xx/staging/read-only/lib/libComponent_mqttClientAzureComponent.so: undefined reference to OPENSSL_add_all_algorithms_noconf’
_build_mqttClientAzure/wp77xx/staging/read-only/lib/libComponent_mqttClientAzureComponent.so: undefined reference to SSL_set_connect_state' _build_mqttClientAzure/wp77xx/staging/read-only/lib/libComponent_mqttClientAzureComponent.so: undefined reference to BIO_ctrl_pending’
_build_mqttClientAzure/wp77xx/staging/read-only/lib/libComponent_mqttClientAzureComponent.so: undefined reference to CRYPTO_set_dynlock_create_callback' _build_mqttClientAzure/wp77xx/staging/read-only/lib/libComponent_mqttClientAzureComponent.so: undefined reference to SSL_get0_param’
_build_mqttClientAzure/wp77xx/staging/read-only/lib/libComponent_mqttClientAzureComponent.so: undefined reference to EVP_cleanup' _build_mqttClientAzure/wp77xx/staging/read-only/lib/libComponent_mqttClientAzureComponent.so: undefined reference to ERR_clear_error’
_build_mqttClientAzure/wp77xx/staging/read-only/lib/libComponent_mqttClientAzureComponent.so: undefined reference to TLSv1_method' _build_mqttClientAzure/wp77xx/staging/read-only/lib/libComponent_mqttClientAzureComponent.so: undefined reference to ERR_free_strings’
_build_mqttClientAzure/wp77xx/staging/read-only/lib/libComponent_mqttClientAzureComponent.so: undefined reference to uuid_generate' _build_mqttClientAzure/wp77xx/staging/read-only/lib/libComponent_mqttClientAzureComponent.so: undefined reference to SSL_CTX_set_default_verify_paths’
_build_mqttClientAzure/wp77xx/staging/read-only/lib/libComponent_mqttClientAzureComponent.so: undefined reference to SSL_CTX_new' _build_mqttClientAzure/wp77xx/staging/read-only/lib/libComponent_mqttClientAzureComponent.so: undefined reference to X509_STORE_add_cert’
_build_mqttClientAzure/wp77xx/staging/read-only/lib/libComponent_mqttClientAzureComponent.so: undefined reference to BIO_new' _build_mqttClientAzure/wp77xx/staging/read-only/lib/libComponent_mqttClientAzureComponent.so: undefined reference to BIO_ctrl’
_build_mqttClientAzure/wp77xx/staging/read-only/lib/libComponent_mqttClientAzureComponent.so: undefined reference to BIO_free' _build_mqttClientAzure/wp77xx/staging/read-only/lib/libComponent_mqttClientAzureComponent.so: undefined reference to SSL_ctrl’
_build_mqttClientAzure/wp77xx/staging/read-only/lib/libComponent_mqttClientAzureComponent.so: undefined reference to x509_openssl_add_credentials' _build_mqttClientAzure/wp77xx/staging/read-only/lib/libComponent_mqttClientAzureComponent.so: undefined reference to ERR_error_string’
_build_mqttClientAzure/wp77xx/staging/read-only/lib/libComponent_mqttClientAzureComponent.so: undefined reference to TLSv1_2_method' _build_mqttClientAzure/wp77xx/staging/read-only/lib/libComponent_mqttClientAzureComponent.so: undefined reference to SSL_set_verify’
_build_mqttClientAzure/wp77xx/staging/read-only/lib/libComponent_mqttClientAzureComponent.so: undefined reference to SSL_CTX_set_cipher_list' _build_mqttClientAzure/wp77xx/staging/read-only/lib/libComponent_mqttClientAzureComponent.so: undefined reference to CRYPTO_set_id_callback’
_build_mqttClientAzure/wp77xx/staging/read-only/lib/libComponent_mqttClientAzureComponent.so: undefined reference to X509_free' _build_mqttClientAzure/wp77xx/staging/read-only/lib/libComponent_mqttClientAzureComponent.so: undefined reference to SSL_CTX_free’
_build_mqttClientAzure/wp77xx/staging/read-only/lib/libComponent_mqttClientAzureComponent.so: undefined reference to SSL_load_error_strings' _build_mqttClientAzure/wp77xx/staging/read-only/lib/libComponent_mqttClientAzureComponent.so: undefined reference to CRYPTO_set_dynlock_destroy_callback’
_build_mqttClientAzure/wp77xx/staging/read-only/lib/libComponent_mqttClientAzureComponent.so: undefined reference to ERR_get_error' _build_mqttClientAzure/wp77xx/staging/read-only/lib/libComponent_mqttClientAzureComponent.so: undefined reference to SSL_CTX_get_cert_store’
_build_mqttClientAzure/wp77xx/staging/read-only/lib/libComponent_mqttClientAzureComponent.so: undefined reference to BIO_puts' _build_mqttClientAzure/wp77xx/staging/read-only/lib/libComponent_mqttClientAzureComponent.so: undefined reference to ENGINE_load_builtin_engines’
_build_mqttClientAzure/wp77xx/staging/read-only/lib/libComponent_mqttClientAzureComponent.so: undefined reference to PEM_read_bio_X509' _build_mqttClientAzure/wp77xx/staging/read-only/lib/libComponent_mqttClientAzureComponent.so: undefined reference to BIO_write’
_build_mqttClientAzure/wp77xx/staging/read-only/lib/libComponent_mqttClientAzureComponent.so: undefined reference to TLSv1_1_method' _build_mqttClientAzure/wp77xx/staging/read-only/lib/libComponent_mqttClientAzureComponent.so: undefined reference to CRYPTO_set_locking_callback’
_build_mqttClientAzure/wp77xx/staging/read-only/lib/libComponent_mqttClientAzureComponent.so: undefined reference to SSL_do_handshake' _build_mqttClientAzure/wp77xx/staging/read-only/lib/libComponent_mqttClientAzureComponent.so: undefined reference to ERR_load_BIO_strings’
_build_mqttClientAzure/wp77xx/staging/read-only/lib/libComponent_mqttClientAzureComponent.so: undefined reference to BIO_s_mem' _build_mqttClientAzure/wp77xx/staging/read-only/lib/libComponent_mqttClientAzureComponent.so: undefined reference to ENGINE_by_id’
_build_mqttClientAzure/wp77xx/staging/read-only/lib/libComponent_mqttClientAzureComponent.so: undefined reference to `SSL_set_bio’

which should be for openssl libraries which are alredy included int the image, so I was wondering how I can solve this without including the source for the openssl library in my app?

You can see here

thank you for that, I am also getting an error for two other functions missing:
uuid_generate' uuid_unparse’
which of the prebuilt libraries are including these?
Normally for linux it should be included in the
util-linux/libuuid/src/gen_uuid.c

But if I include the source directly, build will fail with

error “System with usleep() or nanosleep() required!”

How about this?

I am not linking the library at the moment but including the source of the libuuid.
If you know which library is providing these functions from the existing image:
uuid_generate' uuid_unparse’
I could link the library instead as I have done with ssl and crypto, but I am not even sure if these are included in the build image.

What I have done was to include the libuuid into the source directly, but then I get the error:

error “System with usleep() or nanosleep() required!

where the usleep and nanosleep should be included in the time.c, so I guess I need to link this library so the compiler finds it?
Do you know which one of the image`s libraries is including this?

root@swi-mdm9x28-wp:~# find / -name “uuid
/lib/libuuid.so.1
/lib/libuuid.so.1.3.0

BTW, I add the linker flag “-L -luuid”, after that I can compile the following source code for WP76 FW R13:

#include "legato.h"
#include <uuid/uuid.h>
COMPONENT_INIT
{
    LE_INFO("Hello, world.123");

    uuid_t id;
      uuid_generate(id);

     usleep(100);


  struct timespec tim, tim2;
   tim.tv_sec = 1;
  tim.tv_nsec = 500;
  nanosleep(&tim , &tim2);


}

















10:16:11 **** Incremental Build of configuration Target_Legato_Debug for project hello8 ****
make -C Target_Legato_Debug all 
make: Entering directory `/home/owner/legato/workspace/hello8/Target_Legato_Debug'
cd ..;mkapp -t wp76xx -o Target_Legato_Debug -w Target_Legato_Debug -i "/home/owner/legato/packages/legato.framework.19.2.0.wp76xx-201906171244/resources/legato/interfaces/atServices" -i "/home/owner/legato/packages/legato.framework.19.2.0.wp76xx-201906171244/resources/legato/interfaces/airVantage/legacy" -i "/home/owner/legato/packages/legato.framework.19.2.0.wp76xx-201906171244/resources/legato/interfaces/watchdog" -i "/home/owner/legato/packages/legato.framework.19.2.0.wp76xx-201906171244/resources/legato/interfaces/portService" -i "/home/owner/legato/packages/legato.framework.19.2.0.wp76xx-201906171244/resources/legato/interfaces/supervisor" -i "/home/owner/legato/packages/legato.framework.19.2.0.wp76xx-201906171244/resources/legato/interfaces/logDaemon" -i "/home/owner/legato/packages/legato.framework.19.2.0.wp76xx-201906171244/resources/legato/interfaces/positioning" -i "/home/owner/legato/packages/legato.framework.19.2.0.wp76xx-201906171244/resources/legato/interfaces/secureStorage" -i "/home/owner/legato/packages/legato.framework.19.2.0.wp76xx-201906171244/resources/legato/interfaces" -i "/home/owner/legato/packages/legato.framework.19.2.0.wp76xx-201906171244/resources/legato/interfaces/wifi" -i "/home/owner/legato/packages/legato.framework.19.2.0.wp76xx-201906171244/resources/legato/interfaces/modemServices" -i "/home/owner/legato/packages/legato.framework.19.2.0.wp76xx-201906171244/resources/legato/interfaces/airVantage" -s "/home/owner/legato/packages/legato.framework.19.2.0.wp76xx-201906171244/resources/legato/components/dataConnectionService/platformAdaptor/default" -s "/home/owner/legato/packages/legato.framework.19.2.0.wp76xx-201906171244/resources/legato/components/test/watchdogChain" -s "/home/owner/legato/packages/legato.framework.19.2.0.wp76xx-201906171244/resources/legato/apps/platformServices/airVantageConnector" -s "/home/owner/legato/packages/legato.framework.19.2.0.wp76xx-201906171244/resources/legato/components/airVantage" -s "/home/owner/legato/packages/legato.framework.19.2.0.wp76xx-201906171244/resources/legato/modules/WiFi/apps/tools/wifi" -s "/home/owner/legato/packages/legato.framework.19.2.0.wp76xx-201906171244/resources/legato/components/positioning" -s "/home/owner/legato/packages/legato.framework.19.2.0.wp76xx-201906171244/resources/legato/components/secStore" -s "/home/owner/legato/packages/legato.framework.19.2.0.wp76xx-201906171244/resources/legato/components/uartMode/platformAdaptor/default" -s "/home/owner/legato/packages/legato.framework.19.2.0.wp76xx-201906171244/resources/legato/components/portService" -s "/home/owner/legato/packages/legato.framework.19.2.0.wp76xx-201906171244/resources/legato/components/modemServices/platformAdaptor/default" -s "/home/owner/legato/packages/legato.framework.19.2.0.wp76xx-201906171244/resources/legato/components/audio/platformAdaptor/default" -s "/home/owner/legato/packages/legato.framework.19.2.0.wp76xx-201906171244/resources/legato/apps/tools" -s "/home/owner/legato/packages/legato.framework.19.2.0.wp76xx-201906171244/resources/legato/components/3rdParty" -s "/home/owner/legato/packages/legato.framework.19.2.0.wp76xx-201906171244/resources/legato/components/fwupdate/platformAdaptor/default" -s "/home/owner/legato/packages/legato.framework.19.2.0.wp76xx-201906171244/resources/legato/components/dataConnectionService" -s "/home/owner/legato/packages/legato.framework.19.2.0.wp76xx-201906171244/resources/legato/modules/WiFi/service" -s "/home/owner/legato/packages/legato.framework.19.2.0.wp76xx-201906171244/resources/legato/components/airVantage/platformAdaptor/default" -s "/home/owner/legato/packages/legato.framework.19.2.0.wp76xx-201906171244/resources/legato/components/fwupdate" -s "/home/owner/legato/packages/legato.framework.19.2.0.wp76xx-201906171244/resources/legato/components/positioning/platformAdaptor/default" -s "." -s "/home/owner/legato/packages/legato.framework.19.2.0.wp76xx-201906171244/resources/legato/components/devMode" -s "/home/owner/legato/packages/legato.framework.19.2.0.wp76xx-201906171244/resources/legato/components/secStore/platformAdaptor/default" -s "/home/owner/legato/packages/legato.framework.19.2.0.wp76xx-201906171244/resources/legato/apps/platformServices/mqttClient" -s "/home/owner/legato/packages/legato.framework.19.2.0.wp76xx-201906171244/resources/legato/components/atServices" -s "/home/owner/legato/packages/legato.framework.19.2.0.wp76xx-201906171244/resources/legato/components/modemServices" -s "/home/owner/legato/packages/legato.framework.19.2.0.wp76xx-201906171244/resources/legato/components" -s "/home/owner/legato/packages/legato.framework.19.2.0.wp76xx-201906171244/resources/legato/components/uartMode" -C -g -X -g -L -g -L -luuid hello8.adef
[1/8] Compiling C source
[2/8] Compiling C source
[3/8] Linking C library
[4/8] Bundling file
[5/8] Linking C executable
[6/8] Bundling file
[7/8] Creating info.properties
[8/8] Packaging app
make: Leaving directory `/home/owner/legato/workspace/hello8/Target_Legato_Debug'

10:16:12 Build Finished (took 939ms)