Embedded Linux development: port curl to arm platform (Tiny4412)

1. Environmental introduction

Host:  Redhat 6.3 32 bit

Target development board model:  Friendly arm Tiny4412

Target development board operating system:   use busybox production, the kernel uses the official 3.5 kernel.

Compiler version used:   Cross compiler version 4.5.1 included in the Friendly Arm CD

Two, compile and transplant curl

   The curl command is a file transfer tool that uses URL syntax to work under the command line. It was first released in 1997. It is often used to request a Web server-it can be seen as a browser running on the command line . Its name means the URL tool of the client.

Its function is very powerful, as many as dozens of command line parameters. It supports file upload and download, so it is a comprehensive transmission tool, but traditionally, cURL is used to call it a download tool. CURL also contains the libcurl library for program development, which can be called directly in C language .

The communication protocols supported by cURL are FTP, FTPS, HTTP, HTTPS, TFTP, SFTP, Gopher, SCP, Telnet, DICT, FILE, LDAP, LDAPS, IMAP, POP3, SMTP and RTSP.

curl also supports SSL authentication, HTTP POST, HTTP PUT, FTP upload, HTTP form based upload, proxies, HTTP/2, cookies, username + password authentication (Basic, Plain, Digest, CRAM-MD5, NTLM, Negotiate and Kerberos) , File transfer resume, proxy tunneling.

 

2.1 Download the source code

Source code download address:   https://curl.haxx.se/download.html

2.2 Introduction to curl usage

  Reference article:   https://blog.csdn.net/xiaolong1126626497/article/details/108980098

2.3 Cross compiling curl

[wbyq@wbyq work]$ tar xvf /mnt/hgfs/linux-share-dir/curl-7.73.0.tar.gz 
[wbyq@wbyq work]$ cd curl-7.73.0/
[wbyq@wbyq curl-7.73.0]$ ./configure --prefix=$PWD/_install --host=arm-linux CC=arm-linux-gcc CXX=arm-linux-g++
[wbyq@wbyq curl-7.73.0]$ make && make install

2.4 Deploy the development board operating environment

After the compilation is successful, copy the files in the lib and bin directories in the install directory to the corresponding directory of the development board.

[wbyq@wbyq curl-7.73.0]$ cd _install/
[wbyq@wbyq _install]$ ls
bin  include  lib  share
[wbyq@wbyq _install]$ cp bin/* /home/wbyq/work/rootfs/bin/
[wbyq@wbyq _install]$ cp lib/*.so* /home/wbyq/work/rootfs/lib/

2.5 Test the curl command

Run the test on the development board:

 

Use curl command to visit Baidu homepage: (Note: To access web pages or download files, the network card of the current development board must be connected to the network first, for example, use the Xiaomi portable WIFI to connect to the mobile hotspot first to ensure that you can access the Internet)

[root@wbyq ]# ls
bin         etc         linuxrc     nfs.sh      root        sys         var
code        home        lost+found  opt         rootfs      tmp         work
dev         lib         mnt         proc        sbin        usr
[root@wbyq ]# curl www.baidu.com
<!DOCTYPE html>
<!--STATUS OK--><html> <head><meta http-equiv=content-type content=text/html;charset=utf-8><meta http-equiv=X-UA-Compatible content=IE=Edge><meta content=always name=referrer><link rel=stylesheet type=text/css href=http://s1.bdstatic.com/r/www/cache/bdorz/baidu.min.css><title>百度一下,你就知道</title></head> <body link=#0000cc> <div id=wrapper> <div id=head> <div class=head_wrapper> <div class=s_form> <div class=s_form_wrapper> <div id=lg> <img hidefocus=true src=//www.baidu.com/img/bd_logo1.png width=270 height=129> </div> <form id=form name=f action=//www.baidu.com/s class=fm> <input type=hidden name=bdorz_come value=1> <input type=hidden name=ie value=utf-8> <input type=hidden name=f value=8> <input type=hidden name=rsv_bp value=1> <input type=hidden name=rsv_idx value=1> <input type=hidden name=tn value=baidu><span class="bg s_ipt_wr"><input id=kw name=wd class=s_ipt value maxlength=255 autocomplete=off autofocus></span><span class="bg s_btn_wr"><input type=submit id=su value=百度一下 class="bg s_btn"></span> </form> </div> </div> <div id=u1> <a href=http://news.baidu.com name=tj_trnews class=mnav>新闻</a> <a href=http://www.hao123.com name=tj_trhao123 class=mnav>hao123</a> <a href=http://map.baidu.com name=tj_trmap class=mnav>地图</a> <a href=http://v.baidu.com name=tj_trvideo class=mnav>视频</a> <a href=http://tieba.baidu.com name=tj_trtieba class=mnav>贴吧</a> <noscript> <a href=http://www.baidu.com/bdorz/login.gif?login&amp;tpl=mn&amp;u=http%3A%2F%2Fwww.baidu.com%2f%3fbdorz_come%3d1 name=tj_login class=lb>登录</a> </noscript> <script>document.write('<a href="http://www.baidu.com/bdorz/login.gif?login&tpl=mn&u='+ encodeURIComponent(window.location.href+ (window.location.search === "" ? "?" : "&")+ "bdorz_come=1")+ '" name="tj_login" class="lb">登录</a>');</script> <a href=//www.baidu.com/more/ name=tj_briicon class=bri style="display: block;">更多产品</a> </div> </div> </div> <div id=ftCon> <div id=ftConw> <p id=lh> <a href=http://home.baidu.com>关于百度</a> <a href=http://ir.baidu.com>About Baidu</a> </p> <p id=cp>&copy;2017&nbsp;Baidu&nbsp;<a href=http://www.baidu.com/duty/>使用百度前必读</a>&nbsp; <a href=http://jianyi.baidu.com/ class=cp-feedback>意见反馈</a>&nbsp;京ICP证030173号&nbsp; <img src=//www.baidu.com/img/gs.gif> </p> </div> </div> </div> </body> </html>
[root@wbyq ]# 

Get the weather forecast for the next 7 days in Nanchang:

[root@wbyq ]# ls
bin         etc         linuxrc     nfs.sh      root        sys         var
code        home        lost+found  opt         rootfs      tmp         work
dev         lib         mnt         proc        sbin        usr
[root@wbyq ]# curl "http://api.k780.com:88/?app=weather.future&weaid=??&&appkey=
10003&sign=b59bc3ef6191eb9f747dd4e83c99f2a4&format=json"
{"success":"1","result":[{"weaid":"237","days":"2020-11-14","week":"星期六","cityno":"nanchang","citynm":"南昌","cityid":"101240101","temperature":"23℃/14℃","humidity":"0%/0%","weather":"晴","weather_icon":"http://api.k780.com/upload/weather/d/0.gif","weather_icon1":"http://api.k780.com/upload/weather/n/0.gif","wind":"东北风转北风","winp":"3-4级","temp_high":"23","temp_low":"14","humi_high":"0","humi_low":"0","weatid":"1","weatid1":"1","windid":"1","winpid":"1","weather_iconid":"0","weather_iconid1":"0"},{"weaid":"237","days":"2020-11-15","week":"星期日","cityno":"nanchang","citynm":"南昌","cityid":"101240101","temperature":"25℃/15℃","humidity":"0%/0%","weather":"晴","weather_icon":"http://api.k780.com/upload/weather/d/0.gif","weather_icon1":"http://api.k780.com/upload/weather/n/0.gif","wind":"东北风转北风","winp":"小于3级","temp_high":"25","temp_low":"15","humi_high":"0","humi_low":"0","weatid":"1","weatid1":"1","windid":"1","winpid":"0","weather_iconid":"0","weather_iconid1":"0"},{"weaid":"237","days":"2020-11-16","week":"星期一","cityno":"nanchang","citynm":"南昌","cityid":"101240101","temperature":"25℃/16℃","humidity":"0%/0%","weather":"晴转多云","weather_icon":"http://api.k780.com/upload/weather/d/0.gif","weather_icon1":"http://api.k780.com/upload/weather/n/1.gif","wind":"东北风转北风","winp":"小于3级","temp_high":"25","temp_low":"16","humi_high":"0","humi_low":"0","weatid":"1","weatid1":"2","windid":"1","winpid":"0","weather_iconid":"0","weather_iconid1":"1"},{"weaid":"237","days":"2020-11-17","week":"星期二","cityno":"nanchang","citynm":"南昌","cityid":"101240101","temperature":"27℃/22℃","humidity":"0%/0%","weather":"多云","weather_icon":"http://api.k780.com/upload/weather/d/1.gif","weather_icon1":"http://api.k780.com/upload/weather/n/1.gif","wind":"南风","winp":"小于3级转小于3级","temp_high":"27","temp_low":"22","humi_high":"0","humi_low":"0","weatid":"2","weatid1":"2","windid":"4","winpid":"0","weather_iconid":"1","weather_iconid1":"1"},{"weaid":"237","days":"2020-11-18","week":"星期三","cityno":"nanchang","citynm":"南昌","cityid":"101240101","temperature":"30℃/21℃","humidity":"0%/0%","weather":"多云转小雨","weather_icon":"http://api.k780.com/upload/weather/d/1.gif","weather_icon1":"http://api.k780.com/upload/weather/n/7.gif","wind":"南风转西南风","winp":"4-5级转4-5级","temp_high":"30","temp_low":"21","humi_high":"0","humi_low":"0","weatid":"2","weatid1":"8","windid":"4","winpid":"2","weather_iconid":"1","weather_iconid1":"7"},{"weaid":"237","days":"2020-11-19","week":"星期四","cityno":"nanchang","citynm":"南昌","cityid":"101240101","temperature":"26℃/16℃","humidity":"0%/0%","weather":"小雨转阴","weather_icon":"http://api.k780.com/upload/weather/d/7.gif","weather_icon1":"http://api.k780.com/upload/weather/n/2.gif","wind":"北风","winp":"3-4级","temp_high":"26","temp_low":"16","humi_high":"0","humi_low":"0","weatid":"8","weatid1":"3","windid":"8","winpid":"1","weather_iconid":"7","weather_iconid1":"2"},{"weaid":"237","days":"2020-11-20","week":"星期五","cityno":"nanchang","citynm":"南昌","cityid":"101240101","temperature":"22℃/21℃","humidity":"0%/0%","weather":"阴","weather_icon":"http://api.k780.com/upload/weather/d/2.gif","weather_icon1":"http://api.k780.com/upload/weather/n/2.gif","wind":"北风","winp":"4-5级","temp_high":"22","temp_low":"21","humi_high":"0","humi_low":"0","weatid":"3","weatid1":"3","windid":"8","winpid":"2","weather_iconid":"2","weather_iconid1":"2"}]}[root@wbyq ]# 

 

Guess you like

Origin blog.csdn.net/xiaolong1126626497/article/details/109688207