在嵌入的环境下由于使用的不是标准的发行版本系统,有大部分的软件需要用源码构建;
有一个获取磁盘健康状态的需要,有标准的检查工具,现在用下面的方法进行编译;
github 的项目地址如下
https://github.com/smartmontools/smartmontools
7.5版本的源码下载链接
https://github.com/smartmontools/smartmontools/tree/RELEASE_7_5?tab=readme-ov-file
1、解压源码
>tar -vxf smartmontools-7.5.tar.gz
>cd smartmontools-7.5
2、设置编译器环境变量
#X86 平台
> export CXX=g++
> export CC=gcc
#arm 平台
> export CXX=XXXXXX(自己平台的交叉编译工具路径)g++
> export CC=XXXXXX(自己平台的交叉编译工具路径)gcc
3、配置设置
# --host 程序要运行的目标平台。
# --build 当现在执行 configure 的电脑的架构。
# 注:build必须配置,否则在目标机无法运行。
#--prefix 指定软件安装到的根路径(即 make install 时文件被放到哪里)
#x86 平台的配置如下
>./configure --host=x86_64-linux-gnu --build=x86_64-linux-gnu --prefix=/home/x86
#arm 平台的配置如下
>./configure --host=arm-linux-gnueabihf --build=x86_64-linux-gnu --prefix=/home/arm
4、进行编译
#执行编译
>make
#安装,安装的路径为--prefix 配置的路径
>make install
5、复制到目标机进行运行
#运行smartcl 正常情况如下
~# smartctl --version
smartctl 7.5 2025-04-30 r5714 [xxxxxxxxxxxxxxxxxxxxxxxxx(目标系统架构)] (local build)
Copyright (C) 2002-25, Bruce Allen, Christian Franke, www.smartmontools.org
smartctl comes with ABSOLUTELY NO WARRANTY. This is free
software, and you are welcome to redistribute it under
the terms of the GNU General Public License; either
version 2, or (at your option) any later version.
See https://www.gnu.org for further details.
smartmontools release 7.5 dated 2025-04-30 at 07:42:55 UTC
smartmontools SVN rev 5714 dated 2025-04-30 at 07:43:44
smartmontools build host: arm-unknown-linux-gnueabihf
smartmontools build with: C++11, GCC 5.3.1 20160412
smartmontools configure arguments: '--host=arm-linux-gnueabihf' '--build=x86_64-linux-gnu' ..........................
工具的命令使用可以参考下面的这篇博文
https://post.smzdm.com/p/a94nrnqp/
1278

被折叠的 条评论
为什么被折叠?



