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

Don*_*ild 8 suse rpm architecture

我正在使用以下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
Run Code Online (Sandbox Code Playgroud)

最初我没有使用--target选项,它仍然在 x86 机器上运行,但在 x64 机器上也有同样的错误。

请帮我解决这个错误

小智 9

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

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

--target i386
Run Code Online (Sandbox Code Playgroud)

或者

--target x86_64
Run Code Online (Sandbox Code Playgroud)

它应该为您创建转速。


Bri*_*ard 7

来自关于 rpm、spec 文件和 rpmbuild 的 Fedora 文档:

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.
Run Code Online (Sandbox Code Playgroud)

http://docs.fedoraproject.org/en-US/Fedora_Draft_Documentation/0.1/html/RPM_Guide/ch-rpmbuild.html

所以,正如它所说,确保你安装了额外的编译器(例如 gcc.i686 和 gcc.x86_64)。