How to add OpenSSL Lib while compiling

Hi Team,

I have an Azure IoT Application which uses OpenSSL for TLS security.
I have added and bind the libssl.so.1.0.2 and libcrypto.so.1.0.2 in .cdef file.

When I compile the application I am still getting linker errors, shown below.

/home/ai/myMangOH/mangOH/apps/openssl_vikas/_build_openssl_vikas/wp77xx/component/7f426d7bc8afb4161fdf5c34c1cdbd43/obj/libComponent_azureComponents.so: undefined reference to SSL_get_error' /home/ai/myMangOH/mangOH/apps/openssl_vikas/_build_openssl_vikas/wp77xx/component/7f426d7bc8afb4161fdf5c34c1cdbd43/obj/libComponent_azureComponents.so: undefined reference to ENGINE_free’
/home/ai/myMangOH/mangOH/apps/openssl_vikas/_build_openssl_vikas/wp77xx/component/7f426d7bc8afb4161fdf5c34c1cdbd43/obj/libComponent_azureComponents.so: undefined reference to SSL_write' /home/ai/myMangOH/mangOH/apps/openssl_vikas/_build_openssl_vikas/wp77xx/component/7f426d7bc8afb4161fdf5c34c1cdbd43/obj/libComponent_azureComponents.so: undefined reference to X509_VERIFY_PARAM_set_hostflags’
/home/ai/myMangOH/mangOH/apps/openssl_vikas/_build_openssl_vikas/wp77xx/component/7f426d7bc8afb4161fdf5c34c1cdbd43/obj/libComponent_azureComponents.so: undefined reference to ERR_remove_thread_state' /home/ai/myMangOH/mangOH/apps/openssl_vikas/_build_openssl_vikas/wp77xx/component/7f426d7bc8afb4161fdf5c34c1cdbd43/obj/libComponent_azureComponents.so: undefined reference to SSL_free’

Please help me with the issue.
Thanks,
Pallavi

Did you include the library in .cdef file “requires” section?

Hi jyijyi,

I have resolved the issue by adding linker flags.
Now I am getting new issue, which says

[195/200] Linking C library
/home/ai/.leaf/mangOH-yellow-wp77xx-toolchain_0.2.3-linux64/sysroots/x86_64-pokysdk-linux/usr/libexec/arm-poky-linux-gnueabi/gcc/arm-poky-linux-gnueabi/7.3.0/real-ld: warning: library search path "/usr/lib" is unsafe for cross-compilation
[197/200] Linking C executable
/home/ai/.leaf/mangOH-yellow-wp77xx-toolchain_0.2.3-linux64/sysroots/x86_64-pokysdk-linux/usr/libexec/arm-poky-linux-gnueabi/gcc/arm-poky-linux-gnueabi/7.3.0/real-ld: warning: library search path "/usr/lib" is unsafe for cross-compilation
/home/ai/.leaf/mangOH-yellow-wp77xx-toolchain_0.2.3-linux64/sysroots/x86_64-pokysdk-linux/usr/libexec/arm-poky-linux-gnueabi/gcc/arm-poky-linux-gnueabi/7.3.0/real-ld: warning: library search path "/usr/lib" is unsafe for cross-compilation
[200/200] Packaging app

Its generating update file, but when i run the application on the device. It is getting Aborted Dumped
at the

ssl_ctx = SSL_CTX_new()

Failed to allocate OpenSSL Context

Please help me with this.

Thanks,
Pallavi.

Can you attach a simplied program to reproduce your issue?

Btw, are you using unsandboxed app