By default, Linux libraries are not installed and Linux binary compatibility is not enabled. Linux libraries can either be installed manually or from the FreeBSD Ports Collection.
Before attempting to build the port, load the Linux kernel module, otherwise the build will fail:
For 64-bit compatibility:
To verify that the module is loaded:
kldstatId Refs Address Size Name 1 2 0xc0100000 16bdb8 kernel 7 1 0xc24db000 d000 linux.ko
The emulators/linux_base-c6 package or port is the easiest way to install a base set of Linux libraries and binaries on a FreeBSD system. To install the port:
pkg install emulators/linux_base-c6
For Linux compatibility to be enabled at boot time,
add this line to
On 64-bit machines,
automatically load the module for 64-bit emulation.
Since the Linux binary compatibility layer has gained support for running both 32- and 64-bit Linux binaries (on 64-bit x86 hosts), it is no longer possible to link the emulation functionality statically into a custom kernel.
If a Linux application complains about missing shared libraries after configuring Linux binary compatibility, determine which shared libraries the Linux binary needs and install them manually.
From a Linux system,
ldd can be used
to determine which shared libraries the application needs.
For example, to check which shared libraries
linuxdoom needs, run this command from a
Linux system that has Doom
ldd linuxdoomlibXt.so.3 (DLL Jump 3.1) => /usr/X11/lib/libXt.so.3.1.0 libX11.so.3 (DLL Jump 3.1) => /usr/X11/lib/libX11.so.3.1.0 libc.so.4 (DLL Jump 4.5pl26) => /lib/libc.so.4.6.29
Then, copy all the files in the last column of the output
from the Linux system into
/compat/linux on the FreeBSD system. Once
copied, create symbolic links to the names in the first
column. This example will result in the following files on
the FreeBSD system:
/compat/linux/usr/X11/lib/libXt.so.3.1.0 /compat/linux/usr/X11/lib/libXt.so.3 -> libXt.so.3.1.0 /compat/linux/usr/X11/lib/libX11.so.3.1.0 /compat/linux/usr/X11/lib/libX11.so.3 -> libX11.so.3.1.0 /compat/linux/lib/libc.so.4.6.29 /compat/linux/lib/libc.so.4 -> libc.so.4.6.29
If a Linux shared library already exists with a
matching major revision number to the first column of the
ldd output, it does not need to be copied
to the file named in the last column, as the existing library
should work. It is advisable to copy the shared library if it
is a newer version, though. The old one can be removed, as
long as the symbolic link points to the new one.
For example, these libraries already exist on the FreeBSD system:
/compat/linux/lib/libc.so.4.6.27 /compat/linux/lib/libc.so.4 -> libc.so.4.6.27
ldd indicates that a binary
requires a later version:
libc.so.4 (DLL Jump 4.5pl26) -> libc.so.4.6.29
Since the existing library is only one or two versions out
of date in the last digit, the program should still work with
the slightly older version. However, it is safe to replace
libc.so with the newer
/compat/linux/lib/libc.so.4.6.29 /compat/linux/lib/libc.so.4 -> libc.so.4.6.29
Generally, one will need to look for the shared libraries that Linux binaries depend on only the first few times that a Linux program is installed on FreeBSD. After a while, there will be a sufficient set of Linux shared libraries on the system to be able to run newly installed Linux binaries without any extra work.
ELF binaries sometimes require an extra step. When an unbranded ELF binary is executed, it will generate an error message:
./my-linux-elf-binaryELF binary type not known Abort
To help the FreeBSD kernel distinguish between a FreeBSD ELF binary and a Linux binary, use brandelf(1):
brandelf -t Linux my-linux-elf-binary
Since the GNU toolchain places the appropriate branding information into ELF binaries automatically, this step is usually not necessary.
To install a Linux RPM-based
application, first install the
archivers/rpm4 package or port. Once
use this command to install a
rpm2cpio < /path/to/linux.archive.rpm | cpio -id
brandelf the installed
ELF binaries. Note that this will prevent
a clean uninstall.
If DNS does not work or this error appears:
resolv+: "bind" is an invalid keyword resolv+: "hosts" is an invalid keyword
order hosts, bind multi on
This specifies that
searched first and DNS is searched second.
/compat/linux/etc/host.conf does not
exist, Linux applications use
/etc/host.conf and complain about the
incompatible FreeBSD syntax. Remove
bind if a
name server is not configured using