lipo - macOS


lipo

Overview

lipo (short for “library compatibility”) is a command-line tool used on macOS and other Unix-like operating systems to combine multiple architecture-specific binary files into a single universal binary file. This allows developers to create applications that can run natively on different processor architectures without requiring the user to install separate versions for each architecture.

Syntax

lipo [options] <output> <input1> <input2> ...

Options/Flags

  • -create: Create a new universal binary.
  • -info: Display information about a universal binary.
  • -archs: List the architectures included in a universal binary.
  • -thin: Extract a single architecture from a universal binary.
  • -arch: Specify the architecture to extract when using the -thin option.
  • -extract: Extract all architectures from a universal binary into separate files.
  • -version: Display the version of lipo.
  • -help: Display help information.

Examples

Creating a new universal binary:

lipo -create -output my_universal.bin x86_64_binary.o arm64_binary.o

Displaying information about a universal binary:

lipo -info my_universal.bin

Listing the architectures in a universal binary:

lipo -archs my_universal.bin

Extracting a single architecture from a universal binary:

lipo -thin x86_64 my_universal.bin -output x86_64_binary.o

Extracting all architectures from a universal binary into separate files:

lipo -extract my_universal.bin

Common Issues

  • Error: Bad magic number: This error occurs when lipo is unable to recognize the input file as a valid binary file. Make sure the input file is a valid binary and not a text file or other type of file.
  • Error: Architecture not found: This error occurs when lipo is unable to find the specified architecture in the input file. Make sure the specified architecture is included in the input file.
  • Error: Cannot create universal binary: This error occurs when lipo is unable to create a universal binary from the input files. Make sure the input files are compatible and have the same base architecture.

Integration

lipo can be used in conjunction with other macOS commands and tools for advanced tasks. For example, it can be used with the ld command to create dynamic libraries that can be loaded by applications on different processor architectures.

Related Commands

  • arch
  • ar
  • ld