一次交叉编译搞活记录

一次交叉编译搞活记录,第1张

由于某些神奇的原因 打算交叉编译一下s3fs
环境是arm-linux musleabi

1.编译交叉编译工具链

如果现有交叉编译工具链能够满足需求可以直接使用编译好的交叉编译工具链

交叉编译工具链仓库Files · master · toolchains / musl-cross-make · GitLab

git clone https://git.zv.io/toolchains/musl-cross-make.git
cd musl-cross-make
mv config.mak.dist config.mak

编辑config.mak中的TAGET和MUSL_VER和OUTPUT
TAGET和MUSL_VER要根据平台环境而定
TAGET是选musleabi还是musleabihf可以通过下载一个目标文件通过file指令查看出来
MUSL_VER的话是试错试出来的- -
MUSL 1.1.24由于把time_t大小改了 所以说用错版本会导致编译出来的程序不能用
OUTPUT记得填绝对路径

make && make install

完成编译交叉编译工具链

然后通过

export PATH=$PATH:/root/cross/musl-cross/bin

来建立临时环境变量

2.编译zlib(s3fs->libxml2->zlib)

编译zlib是因为zlib是前置的库文件,至于怎么知道前置的库都有什么,要么看导入的依赖,要么等着报错- -

zlib官网zlib Home Site

http://www.zlib.net/
wget http://www.zlib.net/zlib-1.2.12.tar.gz
tar -zxvf zlib-1.2.12.tar.gz
cd zlib-1.2.12
./configure --prefix=$PWD/_install

修改Makefile
修改CC LDSHARED CPP AR RANLIB变量在参数前加上arm-linux-musleabi-

make && make install

完成交叉编译zlib

3.编译xz(s3fs->libxml2->xz)

xz官网XZ Utils

wget https://tukaani.org/xz/xz-5.2.5.tar.gz
tar -xzvf xz-5.2.5.tar.gz
cd xz-5.2.5
./configure --host=arm-linux-musleabi --prefix=$PWD/_install
make && make install
4.编译python(s3fs->libxml2->python)

python官网Welcome to Python.org

wget https://www.python.org/ftp/python/2.7.18/Python-2.7.18.tar.xz
tar -xvf Python-2.7.18.tar.xz
cd Python-2.7.18
./configure --host=arm-linux-musleabi --build=x86_64-linux --prefix=$PWD/_install --disable-ipv6 ac_cv_file__dev_ptmx=no ac_cv_file__dev_ptc=no
make && make install
5.编译libxml2(s3fs->libxml2)

libxml2官网Index of /sources

wget http://xmlsoft.org/sources/libxml2-2.9.12.tar.gz
tar -xvf libxml2-2.9.12.tar.gz
cd libxml2-2.9.12
./configure --host=arm-linux-musleabi --prefix=$PWD/_install CPPFLAGS="-I/root/cross/zlib-1.2.12/_install/include -I/root/cross/xz-5.2.5/_install/include -I/root/cross/Python-2.7.18/_install/include/python2.7" LDFLAGS="-L/root/cross/zlib-1.2.12/_install/lib -L/root/cross/xz-5.2.5/_install/lib -L/root/cross/Python-2.7.18/_install/lib/python2.7"
make && make install

注意替换依赖路径

6.编译fuse2(s3fs->fuse2)

fuse2仓库地址GitHub - libfuse/libfuse: The reference implementation of the Linux FUSE (Filesystem in Userspace) interface

wget https://github.com/libfuse/libfuse/releases/download/fuse-2.9.9/fuse-2.9.9.tar.gz
tar -xvf fuse-2.9.9.tar.gz
cd fuse-2.9.9
./configure --host=arm-linux-musleabi --prefix=$PWD/_install
make && make install
7.编译openssl(s3fs->curl->openssl)

openssl官网/source/index.html

wget https://www.openssl.org/source/openssl-3.0.2.tar.gz
tar -xvf openssl-3.0.2.tar.gz
cd openssl-3.0.2
./Configure no-asm linux-generic32 --prefix=$PWD/_install --cross-compile-prefix=arm-linux-musleabi- LDFLAGS="-latomic"
make && make install
8.编译curl(s3fs->curl)

curl官网curl

https://curl.se/
wget https://curl.se/download/curl-7.82.0.tar.gz
tar -xvf curl-7.82.0.tar.gz
cd curl-7.82.0
./configure --host=arm-linux-musleabi --prefix=$PWD/_install --with-openssl="/root/cross/openssl-3.0.2/_install" --with-zlib="/root/cross/zlib-1.2.12/_install"
make && make install
9.编译s3fs

s3fs仓库地址https://github.com/s3fs-fuse/s3fs-fuse/

wget https://github.com/s3fs-fuse/s3fs-fuse/archive/refs/tags/v1.91.tar.gz
tar -xvf v1.91.tar.gz
cd s3fs-fuse-1.91
./autogen.sh
export PKG_CONFIG_PATH=/root/cross/fuse-2.9.9/_install/lib/pkgconfig:$PKG_CONFIG_PATH
./configure --host=arm-linux-musleabi --prefix=$PWD/_install DEPS_CFLAGS="-D_FILE_OFFSET_BITS=64 -I/root/cross/libxml2-2.9.12/_install/include/libxml2 -I/root/cross/fuse-2.9.9/_install/include -I/root/cross/curl-7.82.0/_install/include -I/root/cross/openssl-3.0.2/_install/include" LDFLAGS="-L/root/cross/fuse-2.9.9/_install/lib -L/root/cross/libxml2-2.9.12/_install/lib -L/root/cross/openssl-3.0.2/_install/lib -L/root/cross/curl-7.82.0/_install/lib -Wl,-rpath-link=/root/cross/openssl-3.0.2/_install/lib:/root/cross/zlib-1.2.12/_install/lib:/root/cross/xz-5.2.5/_install/lib"
make && make install

之后将s3fs和所需的lib上传至目标机器即可 本次搞活到此结束- -

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/langs/715355.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-04-25
下一篇 2022-04-25

发表评论

登录后才能评论

评论列表(0条)

保存