Skip to content

Create static executable from dynamic executable

License

Notifications You must be signed in to change notification settings

tomkozlowski/staticx

 
 

Repository files navigation

StaticX Build Status PyPI

Bundle dynamic executables with their library dependencies so they can be run anywhere, just like a static executable.

Requirements

StaticX currently works only with Linux 64-bit dynamic executables.

The following external tools need to be installed to run StaticX:

  • ldd - Part of GNU C Library
  • readelf - Part of binutils
  • objcopy - Part of binutils
  • patchelf
    • Packages available for Debian 8+, Fedora 14+, others
    • install with pip install patchelf-wrapper

The following additional tools must be installed to build StaticX from source:

Installation

From PyPI

StaticX is avaiable on PyPI. The wheels are built on Travis CI and include a bootloader built with musl-libc.

You can install using Pip. StaticX is compatible with Python 2.7 (pip) or Python 3.4+ (pip3):

sudo pip3 install staticx

From source

If you have musl libc installed, you can use it to build the staticx bootloader, resulting in smaller, better binaries. Simply set the CC environment variable to your musl-gcc wrapper path:

sudo CC=/usr/local/musl/bin/musl-gcc pip3 install https://github.com/JonathonReinhart/staticx/archive/master.zip

Building from cloned repository

  • Ensure dependencies are installed as above.
  • Change to the root repository directory
  • Run scons
  • Run python setup.py install

Usage

Basic wrapping of an executable

staticx /path/to/exe /path/to/output

Including additional library files with the package (any number can be specified by repeating the -l option)

staticx -l /path/to/fancy/library /path/to/exe /path/to/output

Run-time Information

StaticX sets the following environment variables for the wrapped user program:

  • STATICX_BUNDLE_DIR: The absolute path of the "bundle" directory, the temporary dir where the archive has been extracted.
  • STATICX_PROG_PATH: The absolute path of the program being executed.

License

This software is released under the GPLv2, with an exception allowing the bootloader to be distributed. See LICENSE.txt for more details.

About

Create static executable from dynamic executable

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • C 77.5%
  • Python 19.3%
  • Shell 3.2%