The use of Libcurl in embedded device C

Source: Internet
Author: User
Recently developed a WiFi camera with HiSilicon hi3518e, now use HTTP to implement information push function, such as in the device when the alarm video will push a message "there is an abnormal intrusion." "And a snapshot of the image to the server, and then when the customer's mobile phone online, will be pushed information." Downloaded the Curl Open Source Library on the net, can implement HTTP function with C.

I. Compilation of Curl Library

Curl's download address is http://curl.haxx.se/download.html, detailed compilation steps refer to http://curl.haxx.se/docs/install.html. Here is a brief description of my compilation steps:

>tar Xvzf curl-7.37.0.tar.gz

>CD curl-7.37.0

>./configure--host=arm-none-linux--prefix=/home/hank/http/hisi_http CC=ARM-HISIV100NPTL-LINUX-GCC-- disable-shared--enable-static--without-libidn--without-ssl--without-librtmp--without-gnutls-- Without-libssh2--without-zlib--without-winidn--disable-rtsp--disable-ldap--disable-ldaps

>make

>make Install

Where the CC specifies the compiler,--prefix=/home/hank/http/hisi_http specifies the repository path for make install, which is compiled into a static library, removing some of the functionality.

Second, the use of Curl Library

The following examples refer to the http://blog.csdn.net/sxwyf248/article/details/7984776

Simulate the HTML to be implemented in the C program: [HTML] View plain copy

The C program code is:

[cpp]  View plain  copy #include  <stdio.h>     #include  <string.h >     #include  <curl.h>          int  main (int argc, char *argv[])      {        curl *curl;       CURLcode res;             struct curl_httppost *formpost=NULL;        struct curl_httppost *lastptr=null;       struct curl_slist * headerlist=null;       static const char buf[] =  "Expect : ";            curl_global_init (curl_global_all);             /* fill in the file upload field  */       curl_formadd (&formpost,                     &lastptr,     

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.