libcurl is often used in C-based programs for Linux that need to make HTTP requests. I believe libcurl is included as part of the toolchain distributed with Legato.
Hello @dfrey
Thank you for solution.
I have used curl in my project for http send and receive.
In code, “curl/curl.h” and “curl/easy.h” are included. But still reference error has occurred to all following apiswhile building project:
undefined reference to curl_easy_cleanup' undefined reference to curl_easy_init’
undefined reference to curl_easy_perform' undefined reference to curl_easy_setopt’
undefined reference to curl_easy_strerror' undefined reference to curl_global_cleanup’
console logs:
Target_Legato_Debug/staging/read-only/lib/libComponent_CurlBasedProjectComponent.so: undefined reference to curl_easy_setopt
Target_Legato_Debug/staging/read-only/lib/libComponent_CurlBasedProjectComponent.so: undefined reference to curl_global_cleanup
Target_Legato_Debug/staging/read-only/lib/libComponent_CurlBasedProjectComponent.so: undefined reference to curl_easy_init
Target_Legato_Debug/staging/read-only/lib/libComponent_CurlBasedProjectComponent.so: undefined reference to curl_easy_perform
Target_Legato_Debug/staging/read-only/lib/libComponent_CurlBasedProjectComponent.so: undefined reference to curl_easy_cleanup
Target_Legato_Debug/staging/read-only/lib/libComponent_CurlBasedProjectComponent.so: undefined reference to curl_easy_strerror
The above issue related to ‘undefined reference’ get resolved.
Now I have used curl methods to send data on server link.
But there is one error at curl_easy_perform(curl) : could not resolve host name
My aim is to send Url with GET method so as to receive response of sent link.
along with link, there is some data input to update on server and response is sent back from server.
Code flow:
connected to gprs using le_data api and connection handler
when gprs get connected, curl is initialized and following curl methods :
Setting sandboxing to false isn’t a great solution because it means that your app runs as root and thus any vulnerabilities in your app could lead to a total system takeover. An alternate solution is to bundle an /etc/resolv.conf into the app. I have used this before and listed google DNS servers (eg 8.8.8.8) in the file so that host resolution is likely to work regardless of how you are connected to the internet. Another possible solution is to use “requires file” function of legato to map resolv.conf into the sandbox. I found that this didn’t work the last time I tried because the resolv.conf file is modified when the data connection is established and the modifications aren’t properly reflected inside the sandbox. Maybe give it a try and see if that bug has been fixed though…