如何在x86-64机器上为i386目标构建rpm?


8

我正在使用rpmbuild命令构建一个rpm :

rpmbuild -bb --root <DIRECTORY> --target i386 --define "_topdir <DIRECTORY>" <specfile>.spec

当我使用SLED 10 SP3 x86计算机时,它可以成功运行。但是在我的SLES 10 SP3 x64虚拟机上,它显示以下错误:

error: No compatible architectures found for build

最初我没有使用--targetoption,它仍然在x86机器上运行,但是x64机器上存在相同的错误。

请帮助我解决此错误

Answers:


6

从Fedora文档中获取rpm,spec文件和rpmbuild:

The --target option sets the target architecture at build time. Chapter 3,
Using RPM covers how you can use the --ignoreos and --ignorearch options 
when installing RPMs to ignore the operating system and architecture that 
is flagged within the RPM. Of course, this works only if you are installing 
on a compatible architecture.

On the surface level, the --target option overrides some of the macros in 
the spec file, %_target, %_target_arch, and %_target_os. This flags the RPM 
for the new target platform.

Under the covers, setting the architecture macros is not enough. You really 
cannot create a PowerPC executable, for example, on an Intel-architecture 
machine, unless you have a PowerPC cross compiler, a compiler that can make 
PowerPC executables.

http://docs.fedoraproject.org/zh-CN/Fedora_Draft_Documentation/0.1/html/RPM_Guide/ch-rpmbuild.html

因此,请确保已安装其他编译器(例如gcc.i686和gcc.x86_64)。


是。正如在代码段中所提到的,它的术语是交叉编译器。那就是您需要安装的东西,并且应该如何做就被很好地记录下来(交叉编译虽然不是普通用户经常遇到的东西,但是在开发人员中很常见)。
CVn

3

由于您正在使用“ -bb”标志,这意味着您是从二进制进行构建的,因此您无需为其他体系结构安装编译器。

只需删除规范文件中的“ Buildarch”行,然后从命令行传递它即可

--target i386

要么

--target x86_64

它应该为您创建rpm。

By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.