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 | |
| 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 |
Oliver Pinter | 6e2c075 | 2014-01-16 12:16:21 +0100 | [diff] [blame^] | 31 | or: |
| 32 | $ ./compile.sh bsd |
Nguyen Anh Quynh | f74bebf | 2013-12-09 13:53:11 +0800 | [diff] [blame] | 33 | |
Nguyen Anh Quynh | 26ee41a | 2013-11-27 12:11:31 +0800 | [diff] [blame] | 34 | Then run "./tests/test*" to see the tests disassembling sample code. |
| 35 | |
Nguyen Anh Quynh | a6a1153 | 2013-12-24 17:03:45 +0800 | [diff] [blame] | 36 | - 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] | 37 | |
| 38 | $ ./compile.sh nix32 |
| 39 | |
| 40 | Then similarly, run "./tests/test*" to see the tests disassembling sample code. |
| 41 | |
| 42 | |
| 43 | |
Nguyen Anh Quynh | a6a1153 | 2013-12-24 17:03:45 +0800 | [diff] [blame] | 44 | (2) Install Capstone on *nix |
| 45 | |
| 46 | To install Capstone, run: |
Nguyen Anh Quynh | 26ee41a | 2013-11-27 12:11:31 +0800 | [diff] [blame] | 47 | |
| 48 | $ sudo make install |
| 49 | |
Nguyen Anh Quynh | b2dc054 | 2013-12-09 16:05:49 +0800 | [diff] [blame] | 50 | For FreeBSD/OpenBSD, use 'gmake' instead of 'make': |
Nguyen Anh Quynh | f74bebf | 2013-12-09 13:53:11 +0800 | [diff] [blame] | 51 | |
| 52 | $ sudo gmake install |
| 53 | |
Nguyen Anh Quynh | a6a1153 | 2013-12-24 17:03:45 +0800 | [diff] [blame] | 54 | Users are then required to enter root password to copy Capstone into machine |
| 55 | system directories. |
Nguyen Anh Quynh | 26ee41a | 2013-11-27 12:11:31 +0800 | [diff] [blame] | 56 | |
Nguyen Anh Quynh | a6a1153 | 2013-12-24 17:03:45 +0800 | [diff] [blame] | 57 | NOTE: The core framework that will be installed by "make install" consist of |
| 58 | only following files: |
Nguyen Anh Quynh | 26ee41a | 2013-11-27 12:11:31 +0800 | [diff] [blame] | 59 | |
Patroklos Argyroudis | a6503fe | 2013-11-27 14:25:34 +0200 | [diff] [blame] | 60 | /usr/include/capstone/capstone.h |
| 61 | /usr/include/capstone/x86.h |
| 62 | /usr/include/capstone/arm.h |
| 63 | /usr/include/capstone/arm64.h |
| 64 | /usr/include/capstone/mips.h |
Nguyen Anh Quynh | 26ee41a | 2013-11-27 12:11:31 +0800 | [diff] [blame] | 65 | /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] | 66 | /usr/lib/libcapstone.a |
Nguyen Anh Quynh | 26ee41a | 2013-11-27 12:11:31 +0800 | [diff] [blame] | 67 | |
| 68 | |
| 69 | |
Nguyen Anh Quynh | a6a1153 | 2013-12-24 17:03:45 +0800 | [diff] [blame] | 70 | (3) Cross-compile Windows from *nix |
| 71 | |
| 72 | To cross-compile for Windows, Linux & gcc-mingw-w64-i686 (and also gcc-mingw-w64-x86-64 |
| 73 | for 64-bit binaries) are required. |
Nguyen Anh Quynh | 26ee41a | 2013-11-27 12:11:31 +0800 | [diff] [blame] | 74 | |
| 75 | - To cross-compile Windows 32-bit binary, simply run |
Daniel Godas-Lopez | cf05e11 | 2013-11-28 18:23:39 +0000 | [diff] [blame] | 76 | $ ./compile.sh cross-win32 |
Nguyen Anh Quynh | 26ee41a | 2013-11-27 12:11:31 +0800 | [diff] [blame] | 77 | |
| 78 | - To cross-compile Windows 64-bit binary, simply run |
Daniel Godas-Lopez | cf05e11 | 2013-11-28 18:23:39 +0000 | [diff] [blame] | 79 | $ ./compile.sh cross-win64 |
Nguyen Anh Quynh | 26ee41a | 2013-11-27 12:11:31 +0800 | [diff] [blame] | 80 | |
Nguyen Anh Quynh | a6a1153 | 2013-12-24 17:03:45 +0800 | [diff] [blame] | 81 | 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] | 82 | |
| 83 | |
| 84 | |
Nguyen Anh Quynh | a6a1153 | 2013-12-24 17:03:45 +0800 | [diff] [blame] | 85 | (4) Compile on Windows with Cygwin |
| 86 | |
| 87 | 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] | 88 | |
| 89 | - To compile Windows 32-bit binary under Cygwin, simply run |
| 90 | $ ./compile.sh cygwin-mingw32 |
| 91 | |
| 92 | - To compile Windows 64-bit binary under Cygwin, simply run |
| 93 | $ ./compile.sh cygwin-mingw64 |
| 94 | |
| 95 | |
Oliver Pinter | 6e2c075 | 2014-01-16 12:16:21 +0100 | [diff] [blame^] | 96 | (5) 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] | 97 | |
Oliver Pinter | 6e2c075 | 2014-01-16 12:16:21 +0100 | [diff] [blame^] | 98 | - To use "clang" compiler instead, run command below: |
Nguyen Anh Quynh | a6a1153 | 2013-12-24 17:03:45 +0800 | [diff] [blame] | 99 | |
Oliver Pinter | 6e2c075 | 2014-01-16 12:16:21 +0100 | [diff] [blame^] | 100 | $ ./compile.sh clang |
Nguyen Anh Quynh | 26ee41a | 2013-11-27 12:11:31 +0800 | [diff] [blame] | 101 | |
Oliver Pinter | 6e2c075 | 2014-01-16 12:16:21 +0100 | [diff] [blame^] | 102 | - To use "gcc" compiler instead, run this command: |
| 103 | |
| 104 | $ ./compile.sh gcc |
| 105 | |
Nguyen Anh Quynh | 26ee41a | 2013-11-27 12:11:31 +0800 | [diff] [blame] | 106 | |
| 107 | |
Nguyen Anh Quynh | 676cabd | 2013-12-02 20:23:35 +0800 | [diff] [blame] | 108 | |
Nguyen Anh Quynh | a6a1153 | 2013-12-24 17:03:45 +0800 | [diff] [blame] | 109 | (6) Language bindings |
| 110 | |
| 111 | So far, Python, Ruby, Ocaml, Java, C# and Go are supported by bindings. Look for |
| 112 | the bindings under directory bindings/, and refer to README file of |
| 113 | corresponding languages. |