linux开源库交叉编译汇总

本文详细记录了交叉编译过程中针对不同软件(如openssl, sqlite3, paho-mqtt-c, curl, python3, ffmpeg等)的配置步骤和选项,包括设置prefix, cross-compile-prefix, host, CC等参数,以及如何处理依赖库和错误。此外,还涉及到了gdb, libcoap, i2ctools, qrencode, zlog, gsoap, cunit等工具的编译和安装。整个过程展示了在嵌入式系统开发中构建工具链和库的复杂性和重要性。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

openssl:

makefile中搜索-m64选项并删除,共两处
1.

./config no-asm shared --prefix=$(pwd)/_install --cross-compile-prefix=arm-none-linux-gnueabi-
./config no-asm no-async shared --prefix=$(pwd)/_install --cross-compile-prefix=arm-himix100-linux-
make
make install
  1.  
./config no-asm -shared --prefix=$(pwd)/_install
make CROSS_COMPILE=arm-rockchip-linux-gnueabihf-
make install

sqlite3:

./configure --prefix=`pwd`/_install --host=arm-rockchip-linux-gnueabihf CC=arm-rockchip-linux-gnueabihf-gcc
  • 1

paho-mqtt-c:

  1.  
cmake .. -DCMAKE_INSTALL_PREFIX=$(pwd)/_install -DPAHO_BUILD_STATIC=TRUE -DCMAKE_C_COMPILER=arm-rockchip-linux-gnueabihf-gcc
  1.  
cmake .. -DCMAKE_INSTALL_PREFIX=$(pwd)/_install -DPAHO_BUILD_STATIC=TRUE -DCMAKE_C_COMPILER=arm-rockchip-linux-gnueabihf-gcc -DPAHO_WITH_SSL=TRUE -DCMAKE_C_FLAGS+=$HOME/openssl/_install/include -DCMAKE_LIBRARY_PATH+=$HOME/openssl/_install/lib

curl:

  1.  
./configure --prefix=$(pwd)/_install --host=arm-rockchip-linux-gnueabihf CC=arm-rockchip-linux-gnueabihf-gcc --with-ssl=$HOME/openssl/_install```
  1.  
./configure --prefix=`pwd`/_install --host=arm-rockchip-linux-gnueabihf CC=arm-rockchip-linux-gnueabihf-gcc --without-zlib --without-ssl

python3:

./configure --prefix=`pwd`/_install --host=mipsel-openwrt-linux --build=mips CC=mipsel-openwrt-linux-gcc --enable-shared --disable-ipv6 ac_cv_file__dev_ptc=no ac_cv_file__dev_ptmx=no --enable-optimizations

ffmpeg:

  1. 非交叉编译
./configure --prefix=`pwd`/_install --enable-shared --enable-nonfree --enable-gpl --disable-asm \
--enable-libx264 --enable-libx265 --enable-libmp3lame --enable-libxvid --enable-libfdk-aac --enable-openssl --enable-librtmp \
--extra-cflags='-I$HOME/x264-master/_install/include -I$HOME/lame-3.100/_install/include -I$HOME/xvidcore/build/generic/_install/include -I$HOME/fdk-aac-2.0.1/_install/include -I$HOME/x265_3.2.1/build/_install/include  -I$HOME/openssl-1.0.1u/_install/include  -I$HOME/rtmpdump-2.3/librtmp/_install/include' \
--extra-ldflags='-L$HOME/x264-master/_install/lib -L$HOME/lame-3.100/_install/lib -L$HOME/xvidcore/build/generic/_install/lib -L$HOME/fdk-aac-2.0.1/_install/lib -L$HOME/x265_3.2.1/build/_install/lib  -L$HOME/openssl-1.0.1u/_install/lib -L$HOME/rtmpdump-2.3/librtmp/_install/lib' \
--extra-libs=-ldl
  1. 交叉编译
./configure --prefix=`pwd`/_install --enable-cross-compile --cpu=cortex-a7 --arch=armv7 --target-os=linux  \
--cross-prefix=arm-himix100-linux- --cc=arm-himix100-linux-gcc \
--enable-shared --enable-gpl --disable-asm --enable-pthreads --disable-programs \
--enable-libx264 \
--extra-cflags='-I../x264-master/_install/include' \
--extra-ldflags='-L../x264-master/_install/lib' \
--extra-libs='-ldl -lm -lpthread'
  1. 编译过程可能会报错,可以手动添加PKG_CONFIG_PATH
export PKG_CONFIG_PATH=$HOME/x265_3.2.1/build/_install/lib/pkgconfig:$HOME/rtmpdump-2.3/librtmp/_install/lib/pkgconfig:$HOME/openssl-1.0.1u/_install/lib/pkgconfig

librtmp:

librtmp版本有点旧,需要使用旧的openssl,如openssl-1.0.1u

make prefix=`pwd`/_install XCFLAGS+='-I$HOME/openssl-1.0.1u/_install/include -I$HOME/zlib/_install/include' \
XLDFLAGS+='-L$HOME/openssl-1.0.1u/_install/lib -L$HOME/git/zlib/_install/lib'

libx264:

./configure --prefix=`pwd`/_install --disable-asm --enable-shared --enable-static --enable-pic --host=arm-himix100-linux --cross-prefix=arm-himix100-linux-

nginx:

  1. nginx添加rtmp模块
./configure --add-module=../nginx-rtmp-module --with-http_ssl_module --prefix=`pwd`/_install
  1. nginx添加flv模块
./configure --add-module=../nginx-http-flv-module  --with-http_ssl_module --prefix=`pwd`/_install

Valgrind:

./configure --host=arm-rockchip-linux-gnueabihf CC=arm-rockchip-linux-gnueabihf-gcc CPP=arm-rockchip-linux-gnueabihf-cpp CXX=arm-rockchip-linux-gnueabihf-g++ AR=arm-rockchip-linux-gnueabihf-ar --prefix=`pwd`/_install

dlib:

cmake .. -DCMAKE_INSTALL_PREFIX=./_install -DCMAKE_BUILD_TYPE=Release -DDLIB_NO_GUI_SUPPORT=OFF -DCMAKE_C_COMPILER=arm-rockchip-linux-gnueabihf-gcc -DCMAKE_CXX_COMPILER=arm-rockchip-linux-gnueabihf-g++

gdb:

./configure --prefix=`pwd`/_install --target=arm-rockchip-linux-gnueabihf --host=arm-rockchip-linux-gnueabihf CC=arm-rockchip-linux-gnueabihf-gcc

gdb调试时,可以手动添加链接库
set solib-absolute-prefix “ H O M E / n f s / l i b : HOME/nfs/lib: HOME/nfs/lib:HOME/nfs/usrlib”
set solib-search-path “ H O M E / n f s / l i b : HOME/nfs/lib: HOME/nfs/lib:HOME/nfs/usrlib”

libcoap:

./configure --prefix=`pwd`/_install --disable-doxygen --disable-dtls  --host=mipsel-openwrt-linux CC=$HOME/lede-toolchain-ramips-mt7688_gcc-5.4.0_musl-1.1.16.Linux-x86_64/toolchain-mipsel_24kc_gcc-5.4.0_musl-1.1.16/bin/mipsel-openwrt-linux-gcc --without-openssl  --disable-manpages

i2ctools:

export CC=mipsel-openwrt-linux-gcc
export STRIP=mipsel-openwrt-linux-strip
export AR=mipsel-openwrt-linux-ar
make USE_STATIC_LIB=1 
make install PREFIX=$(pwd)/_install

qrencode:

./configure --prefix=$(pwd)/_install --host=arm-rockchip-linux-gnueabihf CC=arm-rockchip-linux-gnueabihf-gcc --enable-static

zlog:

make PREFIX=$(pwd)/_install CC=arm-rockchip-linux-gnueabihf-gcc
make PREFIX=$(pwd)/_install install

gsoap:

  1. 编译
./configure --prefix=`pwd`/_install --with-openssl=$HOME/openssl-1.0.1u/_install --with-zlib=$HOME/git/zlib/_install --enable-samples
./configure --prefix=`pwd`/_install --disable-c-locale --without-openssl --disable-ssl --enable-samples
  1. 生成onvif客户端、服务端代码(具体细节需要再查询)
./wsdl2h -o onvif.h -P -x -c -s -t ./typemap.dat http://www.onvif.org/onvif/ver10/device/wsdl/devicemgmt.wsdl http://www.onvif.org/onvif/ver10/media/wsdl/media.wsdl http://www.onvif.org/onvif/ver10/event/wsdl/event.wsdl http://www.onvif.org/onvif/ver10/display.wsdl http://www.onvif.org/onvif/ver10/deviceio.wsdl http://www.onvif.org/onvif/ver20/imaging/wsdl/imaging.wsdl http://www.onvif.org/onvif/ver20/ptz/wsdl/ptz.wsdl http://www.onvif.org/onvif/ver10/receiver.wsdl http://www.onvif.org/onvif/ver10/recording.wsdl http://www.onvif.org/onvif/ver10/search.wsdl http://www.onvif.org/onvif/ver10/network/wsdl/remotediscovery.wsdl http://www.onvif.org/onvif/ver10/replay.wsdl http://www.onvif.org/onvif/ver20/analytics/wsdl/analytics.wsdl http://www.onvif.org/onvif/ver10/analyticsdevice.wsdl http://www.onvif.org/ver10/actionengine.wsdl http://www.onvif.org/ver10/pacs/accesscontrol.wsdl http://www.onvif.org/ver10/pacs/doorcontrol.wsdl
./soapcpp2 -L -x -C -2 -I../share/gsoap -I../share/gsoap/import -I../share/gsoap/plugin -I../share/gsoap/custom onvif.h

cunit:

autoheader
automake --add-missing

  1. makefile编译
./configure --prefix=`pwd`/_install --host=arm-rockchip-linux-gnueabihf CC=arm-rockchip-linux-gnueabihf-gcc
  1. cmake编译
cmake -DCMAKE_C_COMPILER=arm-rockchip-linux-gnueabihf-gcc -DCMAKE_INSTALL_PREFIX=`pwd`/_install ../
make install DESTDIR=../_install
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值