Linux 交叉编译(toolchain) ARM aarch64版 libyaml.so 库
前言全局说明
Linux 交叉编译(toolchain) ARM aarch64版 libyaml.so 库
一、说明
环境:
ubuntu 18.04
二、下载源码:
https://github.com/yaml/libyaml
三、环境安装
3.1 ubuntu
sudo apt-get -y install autoconf libtool make
四、编译
4.1 编译环境生效
交叉编译工具链 gcc 和 g++ 路径
export toolchain_BIN=你的编译工具链路径/bin ## Set toolchain export PATH=$toolchain_BIN:$PATH export target_host=aarch64-linux-gnu (修改成你的编译工具名,bin目录里的) export CROSS_COMPILE=${target_host} # export ARCH=arm export ARCH=arm64 export AR=${CROSS_COMPILE}-ar export AS=${CROSS_COMPILE}-as export CC=${CROSS_COMPILE}-gcc export CXX=${CROSS_COMPILE}-g++ export LD=${CROSS_COMPILE}-ld export NM=${CROSS_COMPILE}-nm export OBJDUMP=${CROSS_COMPILE}-objdump export STRIP=${CROSS_COMPILE}-strip
4.2 编译
$ ./bootstrap $ ./configure --host=aarch64-linux-gnu $ make $ make install (一般不安装so到本地系统了,直接拷贝 so 到 arm 机器里即可)
4.3 查看编译结果
ll src/.libs/
注意:.libs 是隐藏文件夹
五、遇到问题:
5.1 AC_PROG_LIBTOOL
qt@qt-vm:~/libyaml-master$ ./bootstrap autoreconf: Entering directory `.' autoreconf: configure.ac: not using Gettext autoreconf: running: aclocal --force autoreconf: configure.ac: tracing autoreconf: configure.ac: creating directory config autoreconf: configure.ac: not using Libtool autoreconf: running: /usr/bin/autoconf --force configure.ac:56: error: possibly undefined macro: AC_PROG_LIBTOOL If this token and others are legitimate, please use m4_pattern_allow. See the Autoconf documentation. autoreconf: /usr/bin/autoconf failed with exit status: 1
解决方法:
https://www.cnblogs.com/y4247464/p/14388334.html
sudo cp /usr/share/aclocal/*.m4 /usr/local/share/aclocal/
5.2 提示--host
qt@qt-vm:~/libyaml-master$ ./configure checking for a BSD-compatible install... /usr/bin/install -c checking whether build environment is sane... yes checking for a thread-safe mkdir -p... /bin/mkdir -p checking for gawk... no checking for mawk... mawk checking whether make sets $(MAKE)... yes checking whether make supports nested variables... yes checking for gcc... aarch64-linux-gnu-gcc checking whether the C compiler works... yes checking for C compiler default output file name... a.out checking for suffix of executables... checking whether we are cross compiling... configure: error: in `/home/qt/avatr-ADAS/libyaml_20200623/libyaml-master': configure: error: cannot run C compiled programs. If you meant to cross compile, use `--host'. See `config.log' for more details
解决方法:
./configure --host=${CROSS_COMPILE}
${CROSS_COMPILE} 是开始设置环境变量时的值
免责声明:本号所涉及内容仅供安全研究与教学使用,如出现其他风险,后果自负。
参考、来源:
https://blog.csdn.net/Fyear100/article/details/93503723
https://blog.csdn.net/turbock/article/details/107718734
https://blog.51cto.com/fengyuzaitu/5645558
https://blog.51cto.com/feather/1695608
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 全程不用写代码,我用AI程序员写了一个飞机大战
· DeepSeek 开源周回顾「GitHub 热点速览」
· 记一次.NET内存居高不下排查解决与启示
· 物流快递公司核心技术能力-地址解析分单基础技术分享
· .NET 10首个预览版发布:重大改进与新特性概览!