Nguyen Anh Quynh | a6a1153 | 2013-12-24 17:03:45 +0800 | [diff] [blame^] | 1 | How To Compile, install & run Capstone for Linux, Mac OSX, *nix 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 | |
| 10 | Out of 4 archtitectures supported by Capstone (Arm, Arm64, Mips & X86), if |
| 11 | you just need several selected archs, you can choose which ones you want |
| 12 | to compile in by modifying config.mk before going to next steps. |
| 13 | |
| 14 | By default, all 4 architectures are compiled. |
| 15 | |
| 16 | |
| 17 | |
| 18 | (1) Compile from source |
| 19 | |
| 20 | On *nix (such as MacOSX, Linux & FreeBSD): |
| 21 | |
| 22 | - To compile for current platform, run either: |
| 23 | |
Nguyen Anh Quynh | 26ee41a | 2013-11-27 12:11:31 +0800 | [diff] [blame] | 24 | $ ./compile.sh |
| 25 | or: |
| 26 | $ make |
| 27 | |
Nguyen Anh Quynh | b2dc054 | 2013-12-09 16:05:49 +0800 | [diff] [blame] | 28 | For FreeBSD/OpenBSD, use 'gmake' instread of 'make': |
Nguyen Anh Quynh | f74bebf | 2013-12-09 13:53:11 +0800 | [diff] [blame] | 29 | |
| 30 | $ gmake |
| 31 | |
Nguyen Anh Quynh | 26ee41a | 2013-11-27 12:11:31 +0800 | [diff] [blame] | 32 | Then run "./tests/test*" to see the tests disassembling sample code. |
| 33 | |
Nguyen Anh Quynh | a6a1153 | 2013-12-24 17:03:45 +0800 | [diff] [blame^] | 34 | - 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] | 35 | |
| 36 | $ ./compile.sh nix32 |
| 37 | |
| 38 | Then similarly, run "./tests/test*" to see the tests disassembling sample code. |
| 39 | |
| 40 | |
| 41 | |
Nguyen Anh Quynh | a6a1153 | 2013-12-24 17:03:45 +0800 | [diff] [blame^] | 42 | (2) Install Capstone on *nix |
| 43 | |
| 44 | To install Capstone, run: |
Nguyen Anh Quynh | 26ee41a | 2013-11-27 12:11:31 +0800 | [diff] [blame] | 45 | |
| 46 | $ sudo make install |
| 47 | |
Nguyen Anh Quynh | b2dc054 | 2013-12-09 16:05:49 +0800 | [diff] [blame] | 48 | For FreeBSD/OpenBSD, use 'gmake' instead of 'make': |
Nguyen Anh Quynh | f74bebf | 2013-12-09 13:53:11 +0800 | [diff] [blame] | 49 | |
| 50 | $ sudo gmake install |
| 51 | |
Nguyen Anh Quynh | a6a1153 | 2013-12-24 17:03:45 +0800 | [diff] [blame^] | 52 | Users are then required to enter root password to copy Capstone into machine |
| 53 | system directories. |
Nguyen Anh Quynh | 26ee41a | 2013-11-27 12:11:31 +0800 | [diff] [blame] | 54 | |
Nguyen Anh Quynh | a6a1153 | 2013-12-24 17:03:45 +0800 | [diff] [blame^] | 55 | NOTE: The core framework that will be installed by "make install" consist of |
| 56 | only following files: |
Nguyen Anh Quynh | 26ee41a | 2013-11-27 12:11:31 +0800 | [diff] [blame] | 57 | |
Patroklos Argyroudis | a6503fe | 2013-11-27 14:25:34 +0200 | [diff] [blame] | 58 | /usr/include/capstone/capstone.h |
| 59 | /usr/include/capstone/x86.h |
| 60 | /usr/include/capstone/arm.h |
| 61 | /usr/include/capstone/arm64.h |
| 62 | /usr/include/capstone/mips.h |
Nguyen Anh Quynh | 26ee41a | 2013-11-27 12:11:31 +0800 | [diff] [blame] | 63 | /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] | 64 | /usr/lib/libcapstone.a |
Nguyen Anh Quynh | 26ee41a | 2013-11-27 12:11:31 +0800 | [diff] [blame] | 65 | |
| 66 | |
| 67 | |
Nguyen Anh Quynh | a6a1153 | 2013-12-24 17:03:45 +0800 | [diff] [blame^] | 68 | (3) Cross-compile Windows from *nix |
| 69 | |
| 70 | To cross-compile for Windows, Linux & gcc-mingw-w64-i686 (and also gcc-mingw-w64-x86-64 |
| 71 | for 64-bit binaries) are required. |
Nguyen Anh Quynh | 26ee41a | 2013-11-27 12:11:31 +0800 | [diff] [blame] | 72 | |
| 73 | - To cross-compile Windows 32-bit binary, simply run |
Daniel Godas-Lopez | cf05e11 | 2013-11-28 18:23:39 +0000 | [diff] [blame] | 74 | $ ./compile.sh cross-win32 |
Nguyen Anh Quynh | 26ee41a | 2013-11-27 12:11:31 +0800 | [diff] [blame] | 75 | |
| 76 | - To cross-compile Windows 64-bit binary, simply run |
Daniel Godas-Lopez | cf05e11 | 2013-11-28 18:23:39 +0000 | [diff] [blame] | 77 | $ ./compile.sh cross-win64 |
Nguyen Anh Quynh | 26ee41a | 2013-11-27 12:11:31 +0800 | [diff] [blame] | 78 | |
Nguyen Anh Quynh | a6a1153 | 2013-12-24 17:03:45 +0800 | [diff] [blame^] | 79 | Resulted files "capstone.dll" and "tests/test*.exe" can then be used on Windows machine. |
Nguyen Anh Quynh | 26ee41a | 2013-11-27 12:11:31 +0800 | [diff] [blame] | 80 | |
| 81 | |
| 82 | |
Nguyen Anh Quynh | a6a1153 | 2013-12-24 17:03:45 +0800 | [diff] [blame^] | 83 | (4) Compile on Windows with Cygwin |
| 84 | |
| 85 | 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] | 86 | |
| 87 | - To compile Windows 32-bit binary under Cygwin, simply run |
| 88 | $ ./compile.sh cygwin-mingw32 |
| 89 | |
| 90 | - To compile Windows 64-bit binary under Cygwin, simply run |
| 91 | $ ./compile.sh cygwin-mingw64 |
| 92 | |
| 93 | |
Nguyen Anh Quynh | a6a1153 | 2013-12-24 17:03:45 +0800 | [diff] [blame^] | 94 | |
| 95 | (5) Compile with clang |
| 96 | |
| 97 | By default, gcc is used as compiler. To use "clang" compiler instead, run command below: |
Nguyen Anh Quynh | 26ee41a | 2013-11-27 12:11:31 +0800 | [diff] [blame] | 98 | |
Nguyen Anh Quynh | 46e8ca8 | 2013-11-28 10:10:50 +0800 | [diff] [blame] | 99 | $ ./compile.sh clang |
Nguyen Anh Quynh | 26ee41a | 2013-11-27 12:11:31 +0800 | [diff] [blame] | 100 | |
| 101 | |
Nguyen Anh Quynh | 676cabd | 2013-12-02 20:23:35 +0800 | [diff] [blame] | 102 | |
Nguyen Anh Quynh | a6a1153 | 2013-12-24 17:03:45 +0800 | [diff] [blame^] | 103 | (6) Language bindings |
| 104 | |
| 105 | So far, Python, Ruby, Ocaml, Java, C# and Go are supported by bindings. Look for |
| 106 | the bindings under directory bindings/, and refer to README file of |
| 107 | corresponding languages. |