Compile & install Capstone

There are several methods to compile and install Capstone. You can view a detailed tutorial for windows and linux here.

1. From source code

Find the source in Download section and follow the instructions in the README file.

The issue with this approach is that at the moment, Windows targets are only possible via Cygwin/MingW cross-compilation. We are working to support Microsoft Visual Studio in the next versions.


2. From repositories

This section explains how to install Capstone on *nix platforms from some software repositories.

2.1 Debian/Ubuntu Linux - core engine

NOTE: At the moment only version 2.1.2 is available in Ubuntu/Debian repositories. Version 3.0.4 will be provided later.

Capstone is available in Ubuntu & Debian Linux (testing/sid flavours). Binary package of the core of Capstone can be installed with:

  $ sudo apt-get install libcapstone2

To write your own tools with Capstone, install the development package with:

  $ sudo apt-get install libcapstone-dev

2.2 Mac OSX - core engine

  $ sudo port install capstone

Note that Macport installs libraries into its own directory, so you need to tell applications where to find them, for example with:

  $ export DYLD_LIBRARY_PATH=/opt/local/lib/:$DYLD_LIBRARY_PATH
  $ brew install capstone

Note that Homebrew installs libraries into its own directory, so you need to tell applications where to find them, for example with:

  $ export DYLD_LIBRARY_PATH=/usr/local/opt/capstone/lib/:$DYLD_LIBRARY_PATH

2.3 FreeBSD - core engine

NOTE: At the moment only version 2.1.2 is available in FreeBSD. Version 3.0.4 will be provided later.

Binary package of the core of Capstone can be installed with:

  # pkg install capstone

Or you can also compile & install from source with:

  # cd /usr/ports/devel/capstone; make install

2.4 OpenBSD - core engine

NOTE: At the moment version 3.0 is available in OpenBSD. Version 3.0.4 is only provided in OpenBSD-current branch.

Capstone is available in OpenBSD from version 5.5. Binary package of the core of Capstone can be installed with:

  $ sudo pkg_add capstone

Or you can also compile & install from source with:

  $ cd /usr/ports/devel/capstone; sudo make install

2.5 NetBSD - core engine

Binary package of the core of Capstone can be installed with:

  $ sudo pkg_add capstone

2.6 Python binding

There are several ways to install Python binding.

2.6.1 Install from source code

The Python binding depends on the core, so make sure to install the core before you can use this binding.

On *nix platforms, do:

$ cd bindings/python
$ sudo make install

On Windows, do:

cd bindings/python
python setup.py install
2.6.2 Install from PyPi package

Our PyPi package include the source code of the core inside, and it will automatically build and install the core library into the same directory with Python module, so if you install from PyPi, there is no need to install the core beforehand.

On *nix platforms (confirmed on Mac OSX, iOS, Android, Linux, *BSD & Solaris), Python binding can be installed using pip, as follows.

  $ sudo pip install capstone

On Windows, you need to install CMake and Microsoft Visual Studio in order to compile the core. Run the following command from Visual Studio developer commandline prompt

  $ pip install capstone

Alternatively, download PyPi package, unzip it, then run the following command from Visual Studio developer commandline prompt.

  python setup.py install
2.6.3 Install from PyPi package - for Windows only

Method above (2.6.2) requires CMake and Visual Studio to compile the core on Windows. In case you cannot or do not want to compile code, use another PyPi capstone-windows package which already has the core prebuilt inside.

On Windows, run the following command from Commandline prompt

  $ pip install capstone-windows

Alternatively, download PyPi package, unzip it, then run the following command from Commandline prompt.

  python setup.py install

3. Precompiled binaries

At the moment precompiled binaries for Windows, Ubuntu, FedoraCore, Python binding & Java are available in our Download section.


Programming

After installation, find in tutorials below how to write your reverse & analysis tools based on Capstone using your favorite programming languages.


Miscellaneous

This section introduces several ways to customize Capstone engine at compile time & clarify the features of our framework.