Compile for 32-bit Haiku under 64-bit Haiku fails

I have a small test program:

#include <stdio.h>

int main()
{
	printf("kecske\n");
	return 0;
}

I compile it with this command:

cc -m32 test.c -o test

And i get this result:

/boot/system/develop/tools/bin/../lib/gcc/x86_64-unknown-haiku/8.3.0/../../../../x86_64-unknown-haiku/bin/ld: skipping incompatible /boot/system/develop/tools/bin/../lib/gcc/x86_64-unknown-haiku/8.3.0/libgcc.a when searching for -lgcc
/boot/system/develop/tools/bin/../lib/gcc/x86_64-unknown-haiku/8.3.0/../../../../x86_64-unknown-haiku/bin/ld: cannot find -lgcc
/boot/system/develop/tools/bin/../lib/gcc/x86_64-unknown-haiku/8.3.0/../../../../x86_64-unknown-haiku/bin/ld: skipping incompatible /boot/system/develop/tools/bin/../lib/gcc/x86_64-unknown-haiku/8.3.0/libgcc_s.so.1 when searching for libgcc_s.so.1
/boot/system/develop/tools/bin/../lib/gcc/x86_64-unknown-haiku/8.3.0/../../../../x86_64-unknown-haiku/bin/ld: cannot find libgcc_s.so.1
/boot/system/develop/tools/bin/../lib/gcc/x86_64-unknown-haiku/8.3.0/../../../../x86_64-unknown-haiku/bin/ld: skipping incompatible /boot/system/develop/tools/bin/../lib/gcc/x86_64-unknown-haiku/8.3.0/libgcc.a when searching for -lgcc
/boot/system/develop/tools/bin/../lib/gcc/x86_64-unknown-haiku/8.3.0/../../../../x86_64-unknown-haiku/bin/ld: cannot find -lgcc
collect2: error: ld returned 1 exit status

I found no 32-bit compatibility libraries for GCC in HaikuDepot nor a 32-bit version of libgcc. How can i compile 32-bit Haiku binaries under a 64-bit Haiku installation?

AFAIK there is no crosscompiler provided in Haikudepot, but you can create an own crosscompiler with the buildtools

káposzta.

I might misunderstood the intention, but this article elaborates compiling for 64-bit under 32-bit and i need the opposite. Or you meant i need to reverse it by hand and build a GCC2 on Haiku amd64?

A káposztát mire írtad? Kecskének dukál? :slight_smile:

No, i meant to build a 32 bit Haiku on 64 bit Haiku you should bootstrap a cross compiler first. You can use this compiler to build 32 bit programs on 64 bit. There is no infrastructure yet to do it easier i fear.

Oh, sorry, wrong link then: https://www.haiku-os.org/guides/building/compiling-x86
Follow the " x86 Compiler Toolset for non-Haiku systems" part, i think.

Pontosan.

This article does not clarify what and where should i get, only the configuring and the flags before the compilation. Or do i need to get the entire Haiku source and build that, or at least the crosscompiler? If yes, then it’s easier to install a 32-bit Haiku beside the 64-bit one.

A crosscompiler should be enough.
Yep, probably it is much easier to use a 32 bit Haiku in QEMU for example.

Okay, thanks. Still, where can i download the crosscompiler’s sources? Maybe i give the hard way a chance.

Thanks. 

It is also possible to use Clang that can compile for everything, but you need binaries for Haiku libraries for different architecture.

There is CLang/LLVM in HaikuDepot, but only for amd64. Is there some kind of “multiarch” possibility as there is in Linux?

1 Like