Build 32-bit UnRAR on a 64-bit System
This guide explains how to cross-compile a 32-bit binary of the UnRAR utility on a 64-bit Linux system. It covers installing the necessary multilib dependencies, obtaining the official source code, passing the required 32-bit compilation flags to the compiler, and verifying that the final generated binary is a 32-bit executable.
1. Install Multilib Dependencies
To compile 32-bit binaries on a 64-bit architecture, your system needs 32-bit standard C/C++ libraries and multilib support for GCC.
On Debian or Ubuntu:
sudo apt update
sudo apt install build-essential gcc-multilib g++-multilib wgetOn Fedora, CentOS, or RHEL:
sudo dnf install gcc gcc-c++ glibc-devel.i686 libstdc++-devel.i686 wget2. Download and Extract the UnRAR Source Code
Obtain the latest official UnRAR source archive directly from RARLAB and extract it:
wget https://www.rarlab.com/rar/unrarsrc-6.2.12.tar.gz
tar -xzf unrarsrc-6.2.12.tar.gz
cd unrar(Note: Replace the version number in the URL with the latest release if necessary.)
3. Compile UnRAR in 32-Bit Mode
The build process uses make with a default
makefile. To force a 32-bit build, you must pass the
-m32 flag to the C++ compiler (CXX), compiler
flags (CXXFLAGS), and linker flags
(LDFLAGS).
Run the following command inside the unrar
directory:
make -f makefile CXX="g++ -m32" CXXFLAGS="-O2 -m32" LDFLAGS="-m32"This compiles all source objects with 32-bit addressing and links them against the 32-bit C/C++ runtime libraries.
4. Verify the Binary Architecture
Once the compilation finishes, an executable named unrar
will be present in the directory. Confirm that it is a 32-bit executable
using the file command:
file unrarThe output should confirm the 32-bit architecture:
unrar: ELF 32-bit LSB pie executable, Intel 80386, version 1 (SYSV)...
5. Install the Binary (Optional)
To make the newly compiled 32-bit binary accessible system-wide, copy
it to /usr/local/bin:
sudo install -m 755 unrar /usr/local/bin/Verify that the binary runs properly:
unrar --version