Home | History | Annotate | Download | only in capstone
      1 This documentation explains how to compile, install & run Capstone on MacOSX,
      2 Linux, *BSD & Solaris. We also show steps to cross-compile for Microsoft Windows.
      3 
      4 To natively compile for Windows using Microsoft Visual Studio, see COMPILE_MSVC.TXT.
      5 
      6 To compile using CMake, see COMPILE_CMAKE.TXT.
      7 
      8 To compile using XCode on MacOSX, see xcode/README.md.
      9 
     10                         *-*-*-*-*-*
     11 
     12 Capstone requires no prerequisite packages, so it is easy to compile & install.
     13 
     14 
     15 
     16 (0) Tailor Capstone to your need.
     17 
     18   Out of 8 archtitectures supported by Capstone (Arm, Arm64, Mips, PPC, Sparc,
     19   SystemZ, XCore & X86), if you just need several selected archs, choose which
     20   ones you want to compile in by editing "config.mk" before going to next steps.
     21 
     22   By default, all 8 architectures are compiled.
     23 
     24   The other way of customize Capstone without having to edit config.mk is to
     25   pass the desired options on the commandline to ./make.sh. Currently,
     26   Capstone supports 5 options, as followings.
     27 
     28   - CAPSTONE_ARCHS: specify list of architectures to compiled in.
     29   - CAPSTONE_USE_SYS_DYN_MEM: change this if you have your own dynamic memory management.
     30   - CAPSTONE_DIET: use this to make the output binaries more compact.
     31   - CAPSTONE_X86_REDUCE: another option to make X86 binary smaller.
     32   - CAPSTONE_X86_ATT_DISABLE: disables AT&T syntax on x86.
     33   - CAPSTONE_STATIC: build static library.
     34   - CAPSTONE_SHARED: build dynamic (shared) library.
     35 
     36   By default, Capstone uses system dynamic memory management, both DIET and X86_REDUCE
     37   modes are disable, and builds all the static & shared libraries.
     38 
     39   To avoid editing config.mk for these customization, we can pass their values to
     40   make.sh, as followings.
     41 
     42   $ CAPSTONE_ARCHS="arm aarch64 x86" CAPSTONE_USE_SYS_DYN_MEM=no CAPSTONE_DIET=yes CAPSTONE_X86_REDUCE=yes ./make.sh
     43 
     44   NOTE: on commandline, put these values in front of ./make.sh, not after it.
     45 
     46   For each option, refer to docs/README for more details.
     47 
     48 
     49 
     50 (1) Compile from source
     51 
     52   On *nix (such as MacOSX, Linux, *BSD, Solaris):
     53 
     54   - To compile for current platform, run:
     55 
     56 		$ ./make.sh
     57 
     58   - On 64-bit OS, run the command below to cross-compile Capstone for 32-bit binary:
     59 
     60 		$ ./make.sh nix32
     61 
     62 
     63 
     64 (2) Install Capstone on *nix
     65 
     66   To install Capstone, run:
     67 
     68 	$ sudo ./make.sh install
     69 
     70 	For FreeBSD/OpenBSD, where sudo is unavailable, run:
     71 
     72 		$ su; ./make.sh install
     73 
     74   Users are then required to enter root password to copy Capstone into machine
     75   system directories.
     76 
     77   Afterwards, run ./tests/test* to see the tests disassembling sample code.
     78 
     79 
     80   NOTE: The core framework installed by "./make.sh install" consist of
     81   following files:
     82 
     83 	/usr/include/capstone/capstone.h
     84 	/usr/include/capstone/x86.h
     85 	/usr/include/capstone/arm.h
     86 	/usr/include/capstone/arm64.h
     87 	/usr/include/capstone/mips.h
     88 	/usr/include/capstone/ppc.h
     89 	/usr/include/capstone/sparc.h
     90 	/usr/include/capstone/systemz.h
     91 	/usr/include/capstone/xcore.h
     92 	/usr/include/capstone/platform.h
     93 	/usr/lib/libcapstone.so (for Linux/*nix), or /usr/lib/libcapstone.dylib (OSX)
     94 	/usr/lib/libcapstone.a
     95 
     96 
     97 
     98 (3) Cross-compile for Windows from *nix
     99 
    100   To cross-compile for Windows, Linux & gcc-mingw-w64-i686 (and also gcc-mingw-w64-x86-64
    101   for 64-bit binaries) are required.
    102 
    103 	- To cross-compile Windows 32-bit binary, simply run:
    104 
    105 		$ ./make.sh cross-win32
    106 
    107 	- To cross-compile Windows 64-bit binary, run:
    108 
    109 		$ ./make.sh cross-win64
    110 
    111   Resulted files libcapstone.dll, libcapstone.dll.a & tests/test*.exe can then
    112   be used on Windows machine.
    113 
    114 
    115 
    116 (4) Cross-compile for iOS from Mac OSX.
    117 
    118   To cross-compile for iOS (iPhone/iPad/iPod), Mac OSX with XCode installed is required. 
    119 
    120 	- To cross-compile for ArmV7 (iPod 4, iPad 1/2/3, iPhone4, iPhone4S), run:
    121 		$ ./make.sh ios_armv7
    122 
    123 	- To cross-compile for ArmV7s (iPad 4, iPhone 5C, iPad mini), run:
    124 		$ ./make.sh ios_armv7s
    125 
    126 	- To cross-compile for Arm64 (iPhone 5S, iPad mini Retina, iPad Air), run:
    127 		$ ./make.sh ios_arm64
    128 
    129 	- To cross-compile for all iDevices (armv7 + armv7s + arm64), run:
    130 		$ ./make.sh ios
    131 
    132   Resulted files libcapstone.dylib, libcapstone.a & tests/test* can then
    133   be used on iOS devices.
    134 
    135 
    136 
    137 (5) Cross-compile for Android
    138 
    139   To cross-compile for Android (smartphone/tablet), Android NDK is required.
    140   NOTE: Only ARM and ARM64 are currently supported.
    141 
    142        $ NDK=/android/android-ndk-r10e ./make.sh cross-android arm
    143        or
    144        $ NDK=/android/android-ndk-r10e ./make.sh cross-android arm64
    145 
    146   Resulted files libcapstone.so, libcapstone.a & tests/test* can then
    147   be used on Android devices.
    148 
    149 
    150 
    151 (6) Compile on Windows with Cygwin
    152 
    153   To compile under Cygwin gcc-mingw-w64-i686 or x86_64-w64-mingw32 run:
    154 
    155         - To compile Windows 32-bit binary under Cygwin, run:
    156 
    157                 $ ./make.sh cygwin-mingw32
    158 
    159         - To compile Windows 64-bit binary under Cygwin, run:
    160 
    161                 $ ./make.sh cygwin-mingw64
    162 
    163   Resulted files libcapstone.dll, libcapstone.dll.a & tests/test*.exe can then
    164   be used on Windows machine.
    165 
    166 
    167 
    168 (7) By default, "cc" (default C compiler on the system) is used as compiler.
    169 
    170 	- To use "clang" compiler instead, run the command below:
    171 
    172 		$ ./make.sh clang
    173 
    174 	- To use "gcc" compiler instead, run:
    175 
    176 		$ ./make.sh gcc
    177 
    178 
    179 
    180 (8) To uninstall Capstone, run the command below:
    181 
    182 		$ sudo ./make.sh uninstall
    183 
    184 
    185 
    186 (9) Language bindings
    187 
    188   So far, Python, Ocaml & Java are supported by bindings in the main code.
    189   Look for the bindings under directory bindings/, and refer to README file
    190   of corresponding languages.
    191 
    192   Community also provide bindings for C#, Go, Ruby, NodeJS, C++ & Vala. Links to
    193   these can be found at address http://capstone-engine.org/download.html
    194