Skip to content

Multilib GCC on ArchLinux

  • by

Some packages like LuaJIT uses native compiler to generate source files which are then used during cross compiling it for another architecture. Now if the target architecture has 32bit word length ( which most of them in embedded space are ) then it expects a matching bitness in compiler on build host. So we need to to use HOST_CC = “gcc -m32” on 64-bit ArchLinux build hosts. This requires multilib to be enabled on ArchLinux

 sudo vim /etc/pacman.conf

add or uncomment

[multilib]
Include = /etc/pacman.d/mirrorlist

Now update and install multilib gcc

sudo pacman -Syu gcc-multilib gcc-libs-multilib

To check the install is done correctly create hello.c with following content

 

#include <stdio.h>
int main() {
  printf("Voila!!\n");
  return 0;
}
$ gcc -m32 ~/hello.c

$ ./a.out

should say

“Voila!!”

Leave a Reply

Your email address will not be published. Required fields are marked *