自学内容网 自学内容网

编译src.rpm源码包的方法

目录

编译方法

报错处理


编译方法

以rpm -ivh /tmp/mlnx-ofa_kernel-5.8-OFED.5.8.1.1.2.1.src.rpm 为例

1,首先确保环境上已经安装了rpmbuild和gcc

yum install rpmbuild   或 yum install rpm-build

yum install rpmdevtools

rpmdev-setuptree

2,安装rpm源码包

rpm -ivh /tmp/mlnx-ofa_kernel-5.8-OFED.5.8.1.1.2.1.src.rpm

#源码包会安装到/root/rpmbuild/SOURCE 它对应的spec放到/root/rpmbuild/SPECS

3,安装依赖包

yum install kernel-devel

4,编出rpm包

cd  ~/rpmbuild/SPECS/

rpmbuild -ba mlnx-ofa_kernel.spec

在/root/rpmbuild/RPMS目录下生成了rpm包

也可以使用指定的目录编译

创建文件夹/tmp/rpmbuild

mkdir /tmp/buildrpm

把helloworld和helloworld.spec 都放入其中<----------------------这一步很关键

cp -r helloworld helloworld.spec /tmp/buildrpm

重新编出rpm包

rpmbuild -ba --buildroot /tmp/buildrpm/ /tmp/buildrpm/helloworld.spec

报错处理

问题原因,查看日志:config.log

会显示让你看config.log

in `/root/rpmbuild/BUILD/mlnx-ofa_kernel-5.8/obj/default/compat 指示了config.log的位置

如果不清楚位置,可以查找:
updatedb

locate config.log

configure: error: in `/root/rpmbuild/BUILD/mlnx-ofa_kernel-5.8/obj/default/compat':

configure: error: no acceptable C compiler found in $PATH

See `config.log' for more details

缺少编译器gcc

configure: error: Kernel source /usr/src/kernels/5.15.67-11.cl9.x86_64 could not be found.

需要安装kernel-devel包

yum install kernel-devel


原文地址:https://blog.csdn.net/bandaoyu/article/details/142832627

免责声明:本站文章内容转载自网络资源,如本站内容侵犯了原著者的合法权益,可联系本站删除。更多内容请关注自学内容网(zxcms.com)!