8

I am building an rpm using rpmbuild command as:

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

When I use my SLED 10 SP3 x86 machine, it runs successfully. But on my SLES 10 SP3 x64 Virtual Machine, it gives following error:

error: No compatible architectures found for build

Initially I was not using --target option, still it was running on x86 machine, but same error was there in x64 machine.

Please help me to resolve this error

Anthon
  • 78,313
  • 42
  • 165
  • 222
0xF1
  • 649
  • 2
  • 8
  • 15

4 Answers4

8

From the Fedora documentation for rpm, spec files, and 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/en-US/Fedora_Draft_Documentation/0.1/html/RPM_Guide/ch-rpmbuild.html

So, as it says, make sure you have the additional compilers installed (for example gcc.i686 & gcc.x86_64).

Brian Redbeard
  • 2,961
  • 19
  • 44
  • Yes. The term for it, as also mentioned in the snippet, is ***cross-compiler***. That's what you need to install, and it should be pretty well documented how to do it (cross compilation, while not something a regular user will encounter very often, is quite common among developers). – user Sep 16 '13 at 07:26
7

Since you are using "-bb" flag which means you are building from binary so you don't need to install compilers for other architectures.

Just get rid of the "Buildarch" line in your spec file and pass it from the command line

--target i386

or

--target x86_64

And it should create the rpms for you.

GAD3R
  • 63,407
  • 31
  • 131
  • 192
adnan kamili
  • 171
  • 1
  • 4
1

The easiest thing to do is spin up a x86 VM and build on it and then copy the i386 or i686 rpms to your x86_64 machine.

Tony
  • 111
  • 1
1

You want: --target i386-redhat-linux

however, this will only work if you have the glibc.i686 and glibc-devel.i686 installed AND you have to have a multiarch compiler capable of emitting 32- and 64-bit code at the same time.

GCC as delivered by Red Hat has been purposely castrated not to be able to do this, even though GCC is perfectly capable of doing it, and does so without much fuss on real UNIX operating systems such as AIX, Solaris, IRIX or even PPC-based Red Hat systems.

So in order to be able to do this, and if (and only if!) you want to use GCC to be able to do this, you must build and package your own version of GCC and explicitly enable a multiarch build, which the GCC ./configure script will not do by default if (and only if!) it detects that GCC is being built on GNU/Linux.

Other alternative would be to install and use either Intel, PGI, or Sun Studio compilers for GNU/Linux, but those compilers are far more pedantic and standards-compliant and will not tolerate many GCC non-portable syntax constructs.

Stephen Kitt
  • 411,918
  • 54
  • 1,065
  • 1,164
Annatar
  • 11
  • 1