当前位置:网站首页>配置交叉编译工具链和环境变量
配置交叉编译工具链和环境变量
2022-07-04 05:30:00 【宁静致远2021】
配置交叉编译工具链和环境变量
原文链接:https://blog.csdn.net/qq_56926420/article/details/122890366
1 设置交叉编译工具链
交叉编译工具链用来在Ubuntu主机上编译应用程序,而这些应用程序是在ARM等其他平台上运行。
设置交叉编译工具主要是设置PATH, ARCH和CROSS_COMPILE三个环境变量,下面介绍具体设置方法。
设置这3个环境变量有多种方法,任意选择其中一种方法即可,建议使用“永久生效”的方法。录制视频时我会使用多种开发板,所以在视频里我总是使用“临时生效”的方法。
库环境变量设置:export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib
export LD_LIBRARY_PATH=/usr/local/X11/lib:$LD_LIBRARY_PATH/
1.1 永久生效
如需永久修改,请修改用户配置文件。
注意:如果不会使用vim命令,可以使用图形化的编辑工具,执行:gedit ~/.bashrc
vim ~/.bashrc
(1)
在行尾添加或修改,加上下面几行(第3行第4行为一行命令):
export ARCH=arm
export CROSS_COMPILE=arm-buildroot-linux-gnueabihf-
export PATH=$PATH:/home/book/100ask_imx6ull-sdk/ToolChain/arm-buildroot-linux-gnueabihf_sdk-buildroot/bin
设置完毕后,要执行 source ~/.bashrc 命令使其生效,这条命令是加载这些设置的环境变量。
设置完毕后,要执行 source ~/.bashrc 命令使其生效,这条命令是加载这些设置的环境变量。
[email protected]:~$ source ~/.bashrc
[email protected]:~$ arm-buildroot-linux-gnueabihf-gcc -v
1.2 临时生效
也可以手工执行“export”命令设置环境变量,该设置只对当前终端有效(另开一个终端需要再次设置)。
(1)
执行以下3个命令,第3个命令很长,需要包含第四行全部复制:
[email protected]:~$ export ARCH=arm
[email protected]:~$ export CROSS_COMPILE=arm-buildroot-linux-gnueabihf-
[email protected]:~$ export PATH=$PATH:/home/book/100ask_imx6ull-sdk/ToolChain/arm-buildroot-linux-gnueabihf_sdk-buildroot/bin
1.3 手动指定
先设置PATH环境变量,然后在make编译时指定ARCH架构 CROSS_COMPILE交叉编译工具链(执行make命令时指定的参数,只对当前命令有效;下次执行make时仍需要再次指定那些参数)。
(1) 示例
[email protected]:~$ export PATH=$PATH:/home/book/100ask_imx6ull-sdk/ToolChain/arm-buildroot-linux-gnueabihf_sdk-buildroot/bin
[email protected]:~$ make ARCH=arm CROSS_COMPILE=arm-buildroot-linux-gnueabihf-
[email protected]:~$ export PATH=$PATH:/home/book/100ask_imx6ull-sdk/ToolChain/gcc-linaro-6.2.1-2016.11-x86_64_arm-linux-gnueabihf/bin
[email protected]:~$ make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf-
2 测试交叉编译工具链
2.1 测试环境变量
[email protected]:~$ echo $ARCH
arm
[email protected]:~$ echo $CROSS_COMPILE
arm-buildroot-linux-gnueabihf-
2.2 测试交叉编译器
执行以下命令,结果见后图:
[email protected]:~$ arm-buildroot-linux-gnueabihf-gcc -v

(1).
配置环境变量一:
使用export命令直接修改PATH的值,
如交叉编译工具链安装完后,
执行以下命令或者执行
export PATH=$PATH:/opt/hisi_linux/x86-arm/arm-himix100-linux/bin
说明:/opt/hisi_linux/x86-arm/arm-himix100-linux/bin为编译安装的目录


(2).配置环境变量二:
通过修改用户目录下的~/.bashrc文件进行配置:
在行尾添加或修改,加上下面一句
export PATH=$PATH:/opt/hisi_linux/x86-arm/arm-himix100-linux/bin
设置完毕后,要执行 source ~/.bashrc 命令使其生效,这条命令是加载这些设置的环境变量。
环境变量配置方法:
直接定义
export
Shell 配置文件
与 Bash Shell 有关的配置文件主要有
/etc/profile
~/.bash_profile
~/.bash_login
~/.profile
~/.bashrc
/etc/bashrc
/etc/bash.bashrc
/etc/profile.d/*.sh
Shell 执行顺序
/etc/profiles->/.profile(/.bash_profile、~/.bash_login)
修改配置文件
全部用户、全部进程共享:/etc/bash.bashrc
一个用户、全部进程共享:~/.bashrc
shell启动方式对变量的影响
子shell进程中执行:/bin/bash会创建shell子进程和./
当前进程中执行:source和.
3 如何添加交叉编译工具链(toolchain)到环境变量?(–sysroot路径)(新:ubuntu交叉编译工具链环境变量的配置)
边栏推荐
- ETCD数据库源码分析——初始化总览
- Ping port artifact psping
- Just do it with your hands 7 - * project construction details 2 - hook configuration
- C # character similarity comparison general class
- ping端口神器psping
- left_and_right_net可解释性设计
- BeanFactoryPostProcessor 与 BeanPostProcessor 相关子类概述
- BUU-Crypto-[GXYCTF2019]CheckIn
- [QT] create mycombobox click event
- [MySQL practice of massive data with high concurrency, high performance and high availability -8] - transaction isolation mechanism of InnoDB
猜你喜欢

Appearance of LabVIEW error dialog box

1480. 一维数组的动态和

Write a complete answer applet (including single choice questions, judgment questions and multiple topics) (III) single choice questions, judgment questions, and the first question display
![[interested reading] advantageous filtering modeling on long term user behavior sequences for click through rate pre](/img/3e/b5df691ca1790469eb1b4e8ea5b4c0.png)
[interested reading] advantageous filtering modeling on long term user behavior sequences for click through rate pre

LabVIEW错误对话框的出现

如何使用postman实现简单的接口关联【增删改查】

Character types of C language

PostgreSQL has officially surpassed mysql. Is this guy too strong!

C # character similarity comparison general class

SQL injection - injection based on MSSQL (SQL Server)
随机推荐
What is MQ?
SQL injection - injection based on MSSQL (SQL Server)
Two sides of the evening: tell me about the bloom filter and cuckoo filter? Application scenario? I'm confused..
Character types of C language
ansys命令
Simulated small root pile
JS扁平化数形结构的数组
BUU-Crypto-[GUET-CTF2019]BabyRSA
left_ and_ right_ Net normal version
js如何将秒转换成时分秒显示
C # character similarity comparison general class
Flink1.13 SQL basic syntax (I) DDL, DML
十二. golang其他
Wechat applet +php realizes authorized login
2022 R2 mobile pressure vessel filling retraining question bank and answers
Tutle clock improved version
空洞卷积、可变形卷积、可变形ROI Pooling
[technology development -25]: integration technology of radio and television network, Internet, telecommunication network and power grid
Simulink and Arduino serial port communication
transformer坑了多少算力