交叉编译环境搭建过程记录

开发环境:x86_64 Ubuntu24.04server
交叉编译链包:arm-linux-gnueabihf-4.7.tar.bz2 arm_32

1. 将交叉编译链解压到/opt

sudo tar -xvjf arm-linux-gnueabihf-4.7.tar.bz2 -C /opt

2. 添加交叉编译PATH路径

vim ~/.bashrc

末尾添加一行

export PATH=/opt/arm-linux-gnueabihf-4.7/bin:$PATH

3.安装32位程序运行环境

  • 因为开发环境是64为系统,交叉编译环境是32位程序,因此需要安装依赖包
sudo dpkg --add-architecture i386
sudo apt update
sudo apt install libc6:i386 libstdc++6:i386 libncurses6:i386 zlib1g:i386
  • 如果出现依赖安装失败,可根据不同系统查找32位程序的支持方法

4.查看安装的交叉编译链

yanghl@yanghl:/$ arm-linux-gnueabihf-gcc --version
arm-linux-gnueabihf-gcc (crosstool-NG linaro-1.13.1-4.7-2013.04-20130415 - Linaro GCC 2013.04) 4.7.3 20130328 (prerelease)
Copyright (C) 2012 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

  • 如上则交叉编译链安装成功,且添加了相应的环境变量,后续可直接使用交叉编译工具进行交叉编译。
posted @ 2025-05-16 15:52  江海余生  阅读(7)  评论(0)    收藏  举报