Nguyen Anh Quynh | b8f2af6 | 2013-12-25 10:49:59 +0800 | [diff] [blame] | 1 | How To Compile, install & run Capstone for Linux, Mac OSX, *BSD and Windows |
Nguyen Anh Quynh | 26ee41a | 2013-11-27 12:11:31 +0800 | [diff] [blame] | 2 | *-*-*-*-*-* |
| 3 | |
Nguyen Anh Quynh | 26ee41a | 2013-11-27 12:11:31 +0800 | [diff] [blame] | 4 | Capstone requires no prerequisite packages, so it is easy to compile & install. |
| 5 | |
| 6 | |
Nguyen Anh Quynh | 26ee41a | 2013-11-27 12:11:31 +0800 | [diff] [blame] | 7 | |
Nguyen Anh Quynh | a6a1153 | 2013-12-24 17:03:45 +0800 | [diff] [blame] | 8 | (0) Tailor Capstone to your need. |
| 9 | |
Nguyen Anh Quynh | 48a14ca | 2014-03-23 08:35:45 +0800 | [diff] [blame] | 10 | Out of 7 archtitectures supported by Capstone (Arm, Arm64, Mips, PPC, Sparc, |
| 11 | SystemZ & X86), if you just need several selected archs, you can choose which ones you |
Nguyen Anh Quynh | 05e2713 | 2014-03-10 11:58:57 +0800 | [diff] [blame] | 12 | want to compile in by modifying "config.mk" before going to next steps. |
Nguyen Anh Quynh | a6a1153 | 2013-12-24 17:03:45 +0800 | [diff] [blame] | 13 | |
Nguyen Anh Quynh | 48a14ca | 2014-03-23 08:35:45 +0800 | [diff] [blame] | 14 | By default, all 7 architectures are compiled. |
Nguyen Anh Quynh | a6a1153 | 2013-12-24 17:03:45 +0800 | [diff] [blame] | 15 | |
Nguyen Anh Quynh | 05e2713 | 2014-03-10 11:58:57 +0800 | [diff] [blame] | 16 | Capstone also supports "diet" engine to minimize the binaries for embedding |
| 17 | purpose. See docs/README for further instructions. |
Nguyen Anh Quynh | a6a1153 | 2013-12-24 17:03:45 +0800 | [diff] [blame] | 18 | |
| 19 | |
Nguyen Anh Quynh | f08ed97 | 2014-04-07 22:13:56 +0800 | [diff] [blame^] | 20 | |
Nguyen Anh Quynh | a6a1153 | 2013-12-24 17:03:45 +0800 | [diff] [blame] | 21 | (1) Compile from source |
| 22 | |
Nguyen Anh Quynh | dba00f8 | 2014-01-17 14:20:54 +0800 | [diff] [blame] | 23 | On *nix (such as MacOSX, Linux, *BSD, Solaris): |
Nguyen Anh Quynh | a6a1153 | 2013-12-24 17:03:45 +0800 | [diff] [blame] | 24 | |
Nguyen Anh Quynh | fe5e7f3 | 2014-01-17 14:56:03 +0800 | [diff] [blame] | 25 | - To compile for current platform, run: |
Nguyen Anh Quynh | a6a1153 | 2013-12-24 17:03:45 +0800 | [diff] [blame] | 26 | |
Nguyen Anh Quynh | dba00f8 | 2014-01-17 14:20:54 +0800 | [diff] [blame] | 27 | $ ./make.sh |
Nguyen Anh Quynh | 26ee41a | 2013-11-27 12:11:31 +0800 | [diff] [blame] | 28 | |
Nguyen Anh Quynh | a6a1153 | 2013-12-24 17:03:45 +0800 | [diff] [blame] | 29 | - On 64-bit OS, run command below to cross-compile Capstone for 32-bit binary: |
Nguyen Anh Quynh | 26ee41a | 2013-11-27 12:11:31 +0800 | [diff] [blame] | 30 | |
Nguyen Anh Quynh | dba00f8 | 2014-01-17 14:20:54 +0800 | [diff] [blame] | 31 | $ ./make.sh nix32 |
Nguyen Anh Quynh | 26ee41a | 2013-11-27 12:11:31 +0800 | [diff] [blame] | 32 | |
| 33 | |
| 34 | |
Nguyen Anh Quynh | a6a1153 | 2013-12-24 17:03:45 +0800 | [diff] [blame] | 35 | (2) Install Capstone on *nix |
| 36 | |
| 37 | To install Capstone, run: |
Nguyen Anh Quynh | 26ee41a | 2013-11-27 12:11:31 +0800 | [diff] [blame] | 38 | |
Nguyen Anh Quynh | dba00f8 | 2014-01-17 14:20:54 +0800 | [diff] [blame] | 39 | $ sudo ./make.sh install |
Nguyen Anh Quynh | 26ee41a | 2013-11-27 12:11:31 +0800 | [diff] [blame] | 40 | |
Nguyen Anh Quynh | dba00f8 | 2014-01-17 14:20:54 +0800 | [diff] [blame] | 41 | For FreeBSD/OpenBSD, where sudo is unavailable, run: |
Nguyen Anh Quynh | f74bebf | 2013-12-09 13:53:11 +0800 | [diff] [blame] | 42 | |
Nguyen Anh Quynh | dba00f8 | 2014-01-17 14:20:54 +0800 | [diff] [blame] | 43 | $ su; ./make.sh install |
Nguyen Anh Quynh | f74bebf | 2013-12-09 13:53:11 +0800 | [diff] [blame] | 44 | |
Nguyen Anh Quynh | a6a1153 | 2013-12-24 17:03:45 +0800 | [diff] [blame] | 45 | Users are then required to enter root password to copy Capstone into machine |
| 46 | system directories. |
Nguyen Anh Quynh | 26ee41a | 2013-11-27 12:11:31 +0800 | [diff] [blame] | 47 | |
Nguyen Anh Quynh | 9919e3b | 2014-01-22 10:17:17 +0800 | [diff] [blame] | 48 | Afterwards, run ./tests/test* to see the tests disassembling sample code. |
Nguyen Anh Quynh | dba00f8 | 2014-01-17 14:20:54 +0800 | [diff] [blame] | 49 | |
| 50 | |
Nguyen Anh Quynh | fe5e7f3 | 2014-01-17 14:56:03 +0800 | [diff] [blame] | 51 | NOTE: The core framework installed by "./make.sh install" consist of |
| 52 | following files: |
Nguyen Anh Quynh | 26ee41a | 2013-11-27 12:11:31 +0800 | [diff] [blame] | 53 | |
Patroklos Argyroudis | a6503fe | 2013-11-27 14:25:34 +0200 | [diff] [blame] | 54 | /usr/include/capstone/capstone.h |
| 55 | /usr/include/capstone/x86.h |
| 56 | /usr/include/capstone/arm.h |
| 57 | /usr/include/capstone/arm64.h |
| 58 | /usr/include/capstone/mips.h |
Nguyen Anh Quynh | dba00f8 | 2014-01-17 14:20:54 +0800 | [diff] [blame] | 59 | /usr/include/capstone/ppc.h |
Nguyen Anh Quynh | 05e2713 | 2014-03-10 11:58:57 +0800 | [diff] [blame] | 60 | /usr/include/capstone/sparc.h |
Nguyen Anh Quynh | 48a14ca | 2014-03-23 08:35:45 +0800 | [diff] [blame] | 61 | /usr/include/capstone/systemz.h |
Nguyen Anh Quynh | 26ee41a | 2013-11-27 12:11:31 +0800 | [diff] [blame] | 62 | /usr/lib/libcapstone.so (for Linux/*nix), or /usr/lib/libcapstone.dylib (OSX) |
Nguyen Anh Quynh | 0427122 | 2013-12-09 11:12:47 +0800 | [diff] [blame] | 63 | /usr/lib/libcapstone.a |
Nguyen Anh Quynh | 26ee41a | 2013-11-27 12:11:31 +0800 | [diff] [blame] | 64 | |
| 65 | |
| 66 | |
Nguyen Anh Quynh | f08ed97 | 2014-04-07 22:13:56 +0800 | [diff] [blame^] | 67 | (3) Cross-compile for Windows from *nix |
Nguyen Anh Quynh | a6a1153 | 2013-12-24 17:03:45 +0800 | [diff] [blame] | 68 | |
| 69 | To cross-compile for Windows, Linux & gcc-mingw-w64-i686 (and also gcc-mingw-w64-x86-64 |
| 70 | for 64-bit binaries) are required. |
Nguyen Anh Quynh | 26ee41a | 2013-11-27 12:11:31 +0800 | [diff] [blame] | 71 | |
Nguyen Anh Quynh | fe5e7f3 | 2014-01-17 14:56:03 +0800 | [diff] [blame] | 72 | - To cross-compile Windows 32-bit binary, simply run: |
Nguyen Anh Quynh | dba00f8 | 2014-01-17 14:20:54 +0800 | [diff] [blame] | 73 | $ ./make.sh cross-win32 |
Nguyen Anh Quynh | 26ee41a | 2013-11-27 12:11:31 +0800 | [diff] [blame] | 74 | |
Nguyen Anh Quynh | fe5e7f3 | 2014-01-17 14:56:03 +0800 | [diff] [blame] | 75 | - To cross-compile Windows 64-bit binary, run: |
Nguyen Anh Quynh | dba00f8 | 2014-01-17 14:20:54 +0800 | [diff] [blame] | 76 | $ ./make.sh cross-win64 |
Nguyen Anh Quynh | 26ee41a | 2013-11-27 12:11:31 +0800 | [diff] [blame] | 77 | |
Nguyen Anh Quynh | 9919e3b | 2014-01-22 10:17:17 +0800 | [diff] [blame] | 78 | Resulted files libcapstone.dll, libcapstone.dll.a & tests/test*.exe can then |
| 79 | be used on Windows machine. |
Nguyen Anh Quynh | 26ee41a | 2013-11-27 12:11:31 +0800 | [diff] [blame] | 80 | |
| 81 | |
| 82 | |
Nguyen Anh Quynh | f08ed97 | 2014-04-07 22:13:56 +0800 | [diff] [blame^] | 83 | (4) Cross-compile for iOS from Mac OSX. |
Nguyen Anh Quynh | 2eecc6c | 2014-04-01 10:22:54 +0800 | [diff] [blame] | 84 | |
| 85 | To cross-compile for iOS (iPhone/iPad/iPod), Mac OSX with XCode installed is required. |
| 86 | |
| 87 | - To cross-compile for ArmV7 (iPod 4, iPad 1/2/3, iPhone4, iPhone4S), run: |
| 88 | $ ./make.sh ios_armv7 |
| 89 | |
| 90 | - To cross-compile for ArmV7s (iPad 4, iPhone 5C, iPad mini), run: |
| 91 | $ ./make.sh ios_armv7s |
| 92 | |
| 93 | - To cross-compile for Arm64 (iPhone 5S, iPad mini Retina, iPad Air), run: |
| 94 | $ ./make.sh ios_arm64 |
| 95 | |
| 96 | - To cross-compile for all iDevices (armv7 + armv7s + arm64), run: |
| 97 | $ ./make.sh ios |
| 98 | |
| 99 | Resulted files libcapstone.dylib, libcapstone.a & tests/test* can then |
| 100 | be used on iOS devices. |
| 101 | |
| 102 | |
| 103 | |
Nguyen Anh Quynh | f08ed97 | 2014-04-07 22:13:56 +0800 | [diff] [blame^] | 104 | (5) Cross-compile for Android |
| 105 | |
| 106 | To cross-compile for Android (smartphone/tablet), Android NDK is required. |
| 107 | |
| 108 | $ ./make.sh cross-android |
| 109 | |
| 110 | Resulted files libcapstone.so, libcapstone.a & tests/test* can then |
| 111 | be used on Android devices. |
| 112 | |
| 113 | |
| 114 | |
| 115 | (6) Compile on Windows with Cygwin |
Nguyen Anh Quynh | a6a1153 | 2013-12-24 17:03:45 +0800 | [diff] [blame] | 116 | |
| 117 | To compile under Cygwin gcc-mingw-w64-i686 or x86_64-w64-mingw32 run: |
Daniel Godas-Lopez | cf05e11 | 2013-11-28 18:23:39 +0000 | [diff] [blame] | 118 | |
| 119 | - To compile Windows 32-bit binary under Cygwin, simply run |
Nguyen Anh Quynh | dba00f8 | 2014-01-17 14:20:54 +0800 | [diff] [blame] | 120 | $ ./make.sh cygwin-mingw32 |
Daniel Godas-Lopez | cf05e11 | 2013-11-28 18:23:39 +0000 | [diff] [blame] | 121 | |
Nguyen Anh Quynh | fe5e7f3 | 2014-01-17 14:56:03 +0800 | [diff] [blame] | 122 | - To compile Windows 64-bit binary under Cygwin, run |
Nguyen Anh Quynh | dba00f8 | 2014-01-17 14:20:54 +0800 | [diff] [blame] | 123 | $ ./make.sh cygwin-mingw64 |
Daniel Godas-Lopez | cf05e11 | 2013-11-28 18:23:39 +0000 | [diff] [blame] | 124 | |
Nguyen Anh Quynh | 9919e3b | 2014-01-22 10:17:17 +0800 | [diff] [blame] | 125 | Resulted files libcapstone.dll, libcapstone.dll.a & tests/test*.exe can then |
| 126 | be used on Windows machine. |
Daniel Godas-Lopez | cf05e11 | 2013-11-28 18:23:39 +0000 | [diff] [blame] | 127 | |
Nguyen Anh Quynh | fe5e7f3 | 2014-01-17 14:56:03 +0800 | [diff] [blame] | 128 | |
Nguyen Anh Quynh | f08ed97 | 2014-04-07 22:13:56 +0800 | [diff] [blame^] | 129 | |
| 130 | (7) By default, "cc" (default C compiler on the system) is used as compiler. |
Nguyen Anh Quynh | a6a1153 | 2013-12-24 17:03:45 +0800 | [diff] [blame] | 131 | |
Oliver Pinter | 6e2c075 | 2014-01-16 12:16:21 +0100 | [diff] [blame] | 132 | - To use "clang" compiler instead, run command below: |
Nguyen Anh Quynh | a6a1153 | 2013-12-24 17:03:45 +0800 | [diff] [blame] | 133 | |
Nguyen Anh Quynh | dba00f8 | 2014-01-17 14:20:54 +0800 | [diff] [blame] | 134 | $ ./make.sh clang |
Nguyen Anh Quynh | 26ee41a | 2013-11-27 12:11:31 +0800 | [diff] [blame] | 135 | |
Nguyen Anh Quynh | fe5e7f3 | 2014-01-17 14:56:03 +0800 | [diff] [blame] | 136 | - To use "gcc" compiler instead, run: |
Oliver Pinter | 6e2c075 | 2014-01-16 12:16:21 +0100 | [diff] [blame] | 137 | |
Nguyen Anh Quynh | dba00f8 | 2014-01-17 14:20:54 +0800 | [diff] [blame] | 138 | $ ./make.sh gcc |
Oliver Pinter | 6e2c075 | 2014-01-16 12:16:21 +0100 | [diff] [blame] | 139 | |
Nguyen Anh Quynh | 26ee41a | 2013-11-27 12:11:31 +0800 | [diff] [blame] | 140 | |
| 141 | |
Nguyen Anh Quynh | f08ed97 | 2014-04-07 22:13:56 +0800 | [diff] [blame^] | 142 | (8) Language bindings |
Nguyen Anh Quynh | a6a1153 | 2013-12-24 17:03:45 +0800 | [diff] [blame] | 143 | |
Nguyen Anh Quynh | 9919e3b | 2014-01-22 10:17:17 +0800 | [diff] [blame] | 144 | So far, Python, Ocaml & Java are supported by bindings in the main code. |
| 145 | Look for the bindings under directory bindings/, and refer to README file |
| 146 | of corresponding languages. |
| 147 | |
| 148 | Community also provide bindings for C#, Go, Ruby & Vala. Links to these can |
| 149 | be found at address http://capstone-engine.org/download.html |