• 微信公众号:美女很有趣。 工作之余,放松一下,关注即送10G+美女照片!

嵌入式Linux开发之第三方库交叉编译

互联网 diligentman 3天前 4次浏览

——————–交叉编译bzip2——————–

需要直接修改Makefile文件如下:

CC=/opt/toolchain/gcc-linaro-5.4.1-2017.05-x86_64_arm-linux-gnueabihf/bin/arm-linux-gnueabihf-gcc

AR=/opt/toolchain/gcc-linaro-5.4.1-2017.05-x86_64_arm-linux-gnueabihf/bin/arm-linux-gnueabihf-ar

RANLIB=/opt/toolchain/gcc-linaro-5.4.1-2017.05-x86_64_arm-linux-gnueabihf/bin/arm-linux-gnueabihf-ranlib

CFLAGS=-Wall -Winline -fPIC -O2 -g $(BIGFILES) PREFIX=/data/library/bzip2-1.0.6/_install

bzip2 -1  < sample1.ref > sample1.rb2

bzip2 -2  < sample2.ref > sample2.rb2

bzip2 -3  < sample3.ref > sample3.rb2

bzip2 -d  < sample1.bz2 > sample1.tst

bzip2 -d  < sample2.bz2 > sample2.tst

bzip2 -ds < sample3.bz2 > sample3.tst

——————–交叉编译pcre-8.44——————–

mkdir _install

CXX=/opt/toolchain/gcc-linaro-5.4.1-2017.05-x86_64_arm-linux-gnueabihf/bin/arm-linux-gnueabihf-g++ CC=/opt/toolchain/gcc-linaro-5.4.1-2017.05-x86_64_arm-linux-gnueabihf/bin/arm-linux-gnueabihf-gcc LD=/opt/toolchain/gcc-linaro-5.4.1-2017.05-x86_64_arm-linux-gnueabihf/bin/arm-linux-gnueabihf-ld AR=/opt/toolchain/gcc-linaro-5.4.1-2017.05-x86_64_arm-linux-gnueabihf/bin/arm-linux-gnueabihf-ar RANLIB=/opt/toolchain/gcc-linaro-5.4.1-2017.05-x86_64_arm-linux-gnueabihf/bin/arm-linux-gnueabihf-ranlib STRIP=/opt/toolchain/gcc-linaro-5.4.1-2017.05-x86_64_arm-linux-gnueabihf/bin/arm-linux-gnueabihf-strip

./configure –prefix=$(pwd)/_install –host=arm-linux –build=i686-pc-linux

make clean && make all && make install

——————–交叉编译zlib-1.2.11——————–

export CC=/opt/toolchain/gcc-linaro-5.4.1-2017.05-x86_64_arm-linux-gnueabihf/bin/arm-linux-gnueabihf-gcc

./configure –prefix=$PWD/_install

make clean && make all && make install

——————–交叉编译lighttpd-1.4.54——————–

注意:lighttpd依赖pcre、zlib、bzip2库

mkdir _install

CXX=/opt/toolchain/gcc-linaro-5.4.1-2017.05-x86_64_arm-linux-gnueabihf/bin/arm-linux-gnueabihf-g++ CC=/opt/toolchain/gcc-linaro-5.4.1-2017.05-x86_64_arm-linux-gnueabihf/bin/arm-linux-gnueabihf-gcc LD=/opt/toolchain/gcc-linaro-5.4.1-2017.05-x86_64_arm-linux-gnueabihf/bin/arm-linux-gnueabihf-ld AR=/opt/toolchain/gcc-linaro-5.4.1-2017.05-x86_64_arm-linux-gnueabihf/bin/arm-linux-gnueabihf-ar RANLIB=/opt/toolchain/gcc-linaro-5.4.1-2017.05-x86_64_arm-linux-gnueabihf/bin/arm-linux-gnueabihf-ranlib STRIP=/opt/toolchain/gcc-linaro-5.4.1-2017.05-x86_64_arm-linux-gnueabihf/bin/arm-linux-gnueabihf-strip PCRECONFIG=/data/library/pcre-8.44/_install/bin/pcre-config LIBS="-L/data/library/pcre-8.44/_install/lib -L/data/library/zlib-1.2.11/_install/lib -L/data/library/bzip2-1.0.6/_install/lib" CFLAGS="$CFLAGS -fPIC -DHAVE_PCRE_H=1 -DHAVE_LIBPCRE=1 -I/data/library/pcre-8.44/_install/include -I/data/library/zlib-1.2.11/_install/include -I/data/library/bzip2-1.0.6/_install/include"

./configure –prefix=$(pwd)/_install –host=arm-linux-gnueabihf –build=i686-pc-linux –enable-shared

make clean && make all && make install

——————–交叉编译openssl-1.1.1f——————–

mkdir _install

./Configure linux-generic32 no-asm shared no-async –prefix=$(pwd)/_install CROSS_COMPILE=/opt/toolchain/gcc-linaro-5.4.1-2017.05-x86_64_arm-linux-gnueabihf/bin/arm-linux-gnueabihf- CC=gcc

make clean && make && make install

——————-交叉编译libevent-2.1.12———————-

注意:libevent依赖openssl库

mkdir _install

CC=/opt/toolchain/gcc-linaro-5.4.1-2017.05-x86_64_arm-linux-gnueabihf/bin/arm-linux-gnueabihf-gcc CXX=/opt/toolchain/gcc-linaro-5.4.1-2017.05-x86_64_arm-linux-gnueabihf/bin/arm-linux-gnueabihf-g++ LDFLAGS="-L/data/library/openssl-1.1.1f/_install/lib" CFLAGS="-I/data/library/openssl-1.1.1f/_install/include"

./configure –prefix=$(pwd)/_install –host=arm-linux-gnueabihf –build=i686-pc-linux

make clean && make all && make install

——————–交叉编译libev-4.33——————–

CC=/opt/toolchain/gcc-linaro-5.4.1-2017.05-x86_64_arm-linux-gnueabihf/bin/arm-linux-gnueabihf-gcc

./configure –prefix=$(pwd)/__install –host=arm-linux-gnueabihf –build=i686-pc-linux

make clean && make all && make install

——————–交叉编译opencv——————–

#!/bin/sh

echo "—– Creating cross-compiled build directory structure"

cd build_arm

echo "—– Setting up compilation"

cmake -DCMAKE_BUILD_TYPE=RELEASE      

            -DCMAKE_INSTALL_PREFIX=../_install    

            -DOPENCV_EXTRA_MODULES_PATH=../opencv_contrib/modules    

            -DCMAKE_TOOLCHAIN_FILE=/opt/toolchain/gcc-linaro-5.4.1-2017.05-x86_64_arm-linux-gnueabihf/bin      

            -DBUILD_TESTS=OFF    

            -DBUILD_EXAMPLES=OFF    

            -DENABLE_NEON=ON      

            -DENABLE_VFPV3=ON      

            -DWITH_TBB=ON    

            -DBUILD_TBB=ON ..

echo "—– Starting compilation"

make -j4 && make install

echo "—– OpenCV correctly built"     

——————–交叉编译ffmpeg——————–

./configure –prefix=$(pwd)/_install –enable_neon

make -j4 && make install -DPTHREAD_LIBRARY=/opt/toolchain/gcc-linaro-5.4.1-2017.05-x86_64_arm-linux-gnueabihf/arm-linux-gnueabihf/libc/usr/lib/libpthread.a -DMATH_LIBRARY=/opt/toolchain/gcc-linaro-5.4.1-2017.05-x86_64_arm-linux-gnueabihf/arm-linux-gnueabihf/libc/usr/lib/libm.a -DRT_LIBRARY=/opt/toolchain/gcc-linaro-5.4.1-2017.05-x86_64_arm-linux-gnueabihf/arm-linux-gnueabihf/libc/usr/lib/librt.a export LD_LIBRARY_PATH=/opt/toolchain/gcc-linaro-5.4.1-2017.05-x86_64_arm-linux-gnueabihf/arm-linux-gnueabihf/libc/lib:$LD_LIBRARY_PATH

——————–交叉编译curl-7.73.0——————–

mkdir _install

./configure –prefix=$(pwd)/_install –host=arm-linux CC=/opt/toolchain/gcc-linaro-5.4.1-2017.05-x86_64_arm-linux-gnueabihf/bin/arm-linux-gnueabihf-gcc CXX=/opt/toolchain/gcc-linaro-5.4.1-2017.05-x86_64_arm-linux-gnueabihf/bin/arm-linux-gnueabihf-g++

make clean && make all && make install

——————–交叉编译curl-7.74.0——————–

依赖于openssl所以需要先编译完openssl并加入资源路径

mkdir _install

./configure –prefix=$(pwd)/_install –host=arm-linux –enable-static –with-ssl=/data/library/openssl-1.1.1f/_install CC=/opt/toolchain/gcc-linaro-5.4.1-2017.05-x86_64_arm-linux-gnueabihf/bin/arm-linux-gnueabihf-gcc CXX=/opt/toolchain/gcc-linaro-5.4.1-2017.05-x86_64_arm-linux-gnueabihf/bin/arm-linux-gnueabihf-g++

make clean && make all && make install

——————–交叉编译apr-1.7.0——————–

mkdir _install

./configure –prefix=$(pwd)/_install –host=arm-linux CC=/opt/toolchain/gcc-linaro-5.4.1-2017.05-x86_64_arm-linux-gnueabihf/bin/arm-linux-gnueabihf-gcc CXX=/opt/toolchain/gcc-linaro-5.4.1-2017.05-x86_64_arm-linux-gnueabihf/bin/arm-linux-gnueabihf-g++ ac_cv_file__dev_zero=yes ac_cv_func_setpgrp_void=yes apr_cv_process_shared_works=yes apr_cv_mutex_robust_shared=yes apr_cv_tcp_nodelay_with_cork=yes ap_void_ptr_lt_long=no

make clean && make all && make install

——————–交叉编译expat-2.2.10——————–

mkdir _install

./configure –prefix=$(pwd)/_install –host=arm-linux CC=/opt/toolchain/gcc-linaro-5.4.1-2017.05-x86_64_arm-linux-gnueabihf/bin/arm-linux-gnueabihf-gcc CXX=/opt/toolchain/gcc-linaro-5.4.1-2017.05-x86_64_arm-linux-gnueabihf/bin/arm-linux-gnueabihf-g++ –without-docbook

make clean && make all && make install

——————–交叉编译apr-util-1.6.1——————–

mkdir _install

./configure –prefix=$(pwd)/_install –host=arm-linux-gnueabihf CC=/opt/toolchain/gcc-linaro-5.4.1-2017.05-x86_64_arm-linux-gnueabihf/bin/arm-linux-gnueabihf-gcc CXX=/opt/toolchain/gcc-linaro-5.4.1-2017.05-x86_64_arm-linux-gnueabihf/bin/arm-linux-gnueabihf-g++ –with-apr=/data/library/apr-1.7.0/_install –with-expat=/data/library/expat-2.2.10/_install

make clean && make all && make install

——————–交叉编译mxml-3.2——————–

mkdir _install

CC=/opt/toolchain/gcc-linaro-5.4.1-2017.05-x86_64_arm-linux-gnueabihf/bin/arm-linux-gnueabihf-gcc

./configure –prefix=$(pwd)/_install –host=arm-linux-gnueabihf –build=i686-pc-linux

make clean && make all && make install

——————–交叉编译OSS C SDK——————–

mkdir _install

cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/home/daniel/Workspace/example/aliyun-oss-c-sdk-master/install/ -DCMAKE_C_COMPILER=/opt/toolchain/gcc-linaro-5.4.1-2017.05-x86_64_arm-linux-gnueabihf/bin/arm-linux-gnueabihf-gcc -DCMAKE_CXX_COMPILER=/opt/toolchain/gcc-linaro-5.4.1-2017.05-x86_64_arm-linux-gnueabihf/bin/arm-linux-gnueabihf-g++ -DCURL_INCLUDE_DIR=/data/library/curl-7.73.0/_install/include/ -DCURL_LIBRARY=/data/library/curl-7.73.0/_install/lib/libcurl.a -DAPR_INCLUDE_DIR=/data/library/apr-1.7.0/_install/include/apr-1/ -DAPR_LIBRARY=/data/library/apr-1.7.0/_install/lib/libapr-1.a -DAPR_UTIL_INCLUDE_DIR=/data/library/apr-util-1.6.1/_install/include/apr-1 -DAPR_UTIL_LIBRARY=/data/library/apr-util-1.6.1/_install/lib/libaprutil-1.a -DMINIXML_INCLUDE_DIR=/data/library/mxml-2.12/_install/include/ -DMINIXML_LIBRARY=/data/library/mxml-2.12/_install/lib/libmxml.a ..

make clean && make all && make install

——————–交叉编译glib——————–

glib交叉编译依赖于libffi和zlib mkdir _install


程序员灯塔
转载请注明原文链接:嵌入式Linux开发之第三方库交叉编译
喜欢 (0)