2616 views|0 replies

3238

Posts

5

Resources
The OP
 

libcurl porting on mtk7688 [Copy link]

                                                             Before porting libcurl to mtk7688, I used libcurl to develop some simple applications on the Linux x86 platform. If I need to port it to the mtk7688 platform, although they both run Linux, cross-compilation is involved due to different chips. I have used a lot of open source libraries recently, and I often cross-compile them, and there are all kinds of errors. I don’t know if it’s because I’m too unlucky or for some other reason. I always get errors when configuring according to the conventional method, but I finally solved it. I have downloaded the latest version of libcurl, version 7.60. If you don't have the source code, you need to download it from the official website. The first step is to enter the following command: ./configure --prefix=/home/wateras/curtest/ CC=mipsel-openwrt-linux-gcc --host=mipsel-linux --enable-static Immediately, an error is reported: checking for nroff... /usr/bin/nroff checking how to use *nroff to get plain text from man pages... -man checking whether to enable the threaded resolver... yes checking whether to use POSIX threads for threaded resolver... auto checking pthread.h usability... yes checking pthread.h presence... yes checking for pthread.h... yes checking for pthread_create... no checking for pthread_create in -lpthread... no configure: error: Threaded resolver enabled but no thread library found : Unexpectedly, the first step failed. The error shows that we enabled the multi-threaded resolver, but there is no thread library. The problem is that I didn’t use it, so I disabled it. Then I entered the following command: ./configure --prefix=/home/wateras/curtest/ CC=mipsel-openwrt-linux-gcc --host=mipsel-linux --disable-threaded-resolver --enable-static Output: config.status: creating packages/AIX/RPM/curl.spec config.status: creating curl-config config.status: creating libcurl.pc config.status: creating lib/curl_config.h config.status: lib/curl_config.h is unchanged config.status: executing depfiles commands config.status: executing libtool commands configure: amending lib/Makefile configure: amending src/Makefile configure: amending tests/unit/Makefile configure: amending tests/server/Makefile configure: amending tests/libtest/Makefile configure: amending docs/examples/Makefile configure: Configured to build curl/libcurl: curl version: 7.60.0 Host setup: mipsel-unknown-linux-gnu Install prefix: /home/wateras/curtest Compiler: mipsel-openwrt-linux-gcc SSL support: no (--with-{ssl,gnutls, nss,polarssl,mbedtls,cyassl,axtls,winssl,darwinssl} ) SSH support: no (--with-libssh2) zlib support: no (--with-zlib) brotli support: no (--with-brotli) GSS-API support: no (--with-gssapi) TLS-SRP support: no (--enable-tls-srp) resolver: default (--enable-are s/ --enable-threaded-resolver) IPv6 support: enabled Unix sockets support: enabled IDN support: no (--with-{libidn2,winidn}) Build libcurl: Shared=yes, Static=yes Built-in manual: enabled --libcurl option: enabled (--disable-libcurl-option) Verbose errors: enabled (--disable-verbose) SSPI support: no (--enable-sspi) ca cert bundle: no ca cert path: ca fallback: LDAP support: no (--enable-ldap / --with-ldap-lib / --with-lber-lib) LDAPS support: no (--enable-ldaps) RTSP support: enabled RTMP support: no (--with-librtmp) metalink support: no (--with-libmetalink) PSL support:/home/wateras/curtest/curl/include -L/home/wateras/curtest/lib -lcurl mipsel-openwrt-linux-uclibc-gcc.bin: warning: environment variable 'STAGING_DIR' not defined mipsel-openwrt-linux-gcc -g -Wall -o main main.o -I/home/wateras/curtest/curl/include -L/home/wateras/curtest/lib -lcurl mipsel-openwrt-linux-uclibc-gcc.bin: warning: environment variable 'STAGING_DIR' not defined mipsel-openwrt-linux-uclibc-gcc.bin: warning: environment variable 'STAGING_DIR' not defined wateras@wateras-virtual-machine:~/curtest$ ./main bash: ./main: cannot execute binary file: Executable file format error wateras@wateras-virtual-machine:~/curtest$ ls -al Total usage 10468 drwxrwxr-x 8 wateras wateras 4096 6月21 10:39 . drwxr-xr-x 46 wateras wateras 4096 6月21 10:39 .. drwxrwxr-x 2 wateras wateras 4096 6月21 10:30 bin drwxr-xr-x 2 wateras wateras 4096 May 30 15:37 curl drwxr-xr-x 13 wateras wateras 4096 June 21 09:58 curl-7.60.0 -rw-rw-r-- 1 wateras wateras 3949173 May 16 14:19 curl-7.60.0.tar.gz drwx rwxr-x 3 wateras wateras 4096 June 21 10:30 include drwxrwxr-x 3 wateras wateras 4096 June 21 10:30 lib -rwxrwxr-x 1 wateras wateras 30010 June 21 10:39 main -rw-rw-r-- 1 wateras wateras 3153 June 21 10:39 main.c -rw-rw-r-- 1 wateras wateras 29536 June 21 10:39 main.o -rw-rw-r-- 1 wateras wateras 273 June 21 10:33 Makefile -rw-rw-r-- 1 wateras wateras 185 June 20 15:34 Makefile11 1 drwxrwxr-x 4 wateras wateras 4096 June 21 10:30 share -rw-rw-r-- 1 wateras wateras 6291460 June 20 14:39 user2.bin -rw-rw-r-- 1 wateras wateras 357380 June 19 17:25 user.bin From the red font we can see that the generated main executable file is already running on mtk7688. If you don’t believe it, you can use the following command to verify itwateras@wateras-virtual-machine:~/curtest$ file main main: ELF 32-bit LSB executable, MIPS, MIPS32 rel2 version 1, dynamically linked (uses shared libs), not strippedThe commonly used commands for viewing executable files are as follows:

1. file executable file can view whether the executable file is ARM architecture or X86 architecture

2. nm executable file can view the symbols in the file, including global variables, global functions, etc.

3. The ldd executable file can view the dynamic libraries required for file execution

4. The strings executable file can view all symbols in the file, including compiler version information

5. The readelf executable file can view all detailed information of the file, including the file's header information, dynamic library information, segment information, etc.

Next, put the main executable file on the mtk7688 platform to run

My test code is to use curl to download files. The main process is to cross-compile lib files, which takes some effort. Various errors will pop up every time, so I solve the problem like Shennong Baicao. The above aspects can be transplanted on any chip architecture. For example, under the common ARM platform, CC and host can be modified, and no other modifications are required (Linux system). This content is original by EEWORLD forum user wateras1. If you need to reprint or use it for commercial purposes, you must obtain the author's consent and indicate the source


This post is from RF/Wirelessly
Personal signature淘宝:https://viiot.taobao.com/Q群243090717
多年专业物联网行业经验,个人承接各类物联网外包项目
 

Find a datasheet?

EEWorld Datasheet Technical Support

快速回复 返回顶部 Return list