Nguyen Anh Quynh | 26ee41a | 2013-11-27 12:11:31 +0800 | [diff] [blame] | 1 | How To Compile & Run Capstone for Linux, Mac OSX, *nix and Windows |
| 2 | *-*-*-*-*-* |
| 3 | |
| 4 | |
| 5 | Capstone requires no prerequisite packages, so it is easy to compile & install. |
| 6 | |
| 7 | |
Nguyen Anh Quynh | f74bebf | 2013-12-09 13:53:11 +0800 | [diff] [blame^] | 8 | (1) On *nix (such as MacOSX, Linux & FreeBSD): |
Nguyen Anh Quynh | 26ee41a | 2013-11-27 12:11:31 +0800 | [diff] [blame] | 9 | |
| 10 | - To compile for current platform, run either: |
| 11 | $ ./compile.sh |
| 12 | or: |
| 13 | $ make |
| 14 | |
Nguyen Anh Quynh | f74bebf | 2013-12-09 13:53:11 +0800 | [diff] [blame^] | 15 | For FreeBSD, use 'gmake' instread of 'make': |
| 16 | |
| 17 | $ gmake |
| 18 | |
Nguyen Anh Quynh | 26ee41a | 2013-11-27 12:11:31 +0800 | [diff] [blame] | 19 | Then run "./tests/test*" to see the tests disassembling sample code. |
| 20 | |
Nguyen Anh Quynh | 2cd3370 | 2013-12-02 20:32:41 +0800 | [diff] [blame] | 21 | - 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] | 22 | |
| 23 | $ ./compile.sh nix32 |
| 24 | |
| 25 | Then similarly, run "./tests/test*" to see the tests disassembling sample code. |
| 26 | |
| 27 | |
| 28 | |
| 29 | (2) To install Capstone, run: |
| 30 | |
| 31 | $ sudo make install |
| 32 | |
Nguyen Anh Quynh | f74bebf | 2013-12-09 13:53:11 +0800 | [diff] [blame^] | 33 | For FreeBSD, use 'gmake' instead of 'make': |
| 34 | |
| 35 | $ sudo gmake install |
| 36 | |
Nguyen Anh Quynh | 2cd3370 | 2013-12-02 20:32:41 +0800 | [diff] [blame] | 37 | Users are then required to enter root password to copy Capstone into machine |
Nguyen Anh Quynh | 26ee41a | 2013-11-27 12:11:31 +0800 | [diff] [blame] | 38 | system directories. |
| 39 | |
| 40 | NOTE: The core framework that will be installed by "make install" consist of |
| 41 | only following files: |
| 42 | |
Patroklos Argyroudis | a6503fe | 2013-11-27 14:25:34 +0200 | [diff] [blame] | 43 | /usr/include/capstone/capstone.h |
| 44 | /usr/include/capstone/x86.h |
| 45 | /usr/include/capstone/arm.h |
| 46 | /usr/include/capstone/arm64.h |
| 47 | /usr/include/capstone/mips.h |
Nguyen Anh Quynh | 26ee41a | 2013-11-27 12:11:31 +0800 | [diff] [blame] | 48 | /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] | 49 | /usr/lib/libcapstone.a |
Nguyen Anh Quynh | 26ee41a | 2013-11-27 12:11:31 +0800 | [diff] [blame] | 50 | |
| 51 | |
| 52 | |
| 53 | (3) To cross-compile for Windows, Linux & gcc-mingw-w64-i686 (and also gcc-mingw-w64-x86-64 |
Nguyen Anh Quynh | 2cd3370 | 2013-12-02 20:32:41 +0800 | [diff] [blame] | 54 | for 64-bit binaries) are required. |
Nguyen Anh Quynh | 26ee41a | 2013-11-27 12:11:31 +0800 | [diff] [blame] | 55 | |
| 56 | - To cross-compile Windows 32-bit binary, simply run |
Daniel Godas-Lopez | cf05e11 | 2013-11-28 18:23:39 +0000 | [diff] [blame] | 57 | $ ./compile.sh cross-win32 |
Nguyen Anh Quynh | 26ee41a | 2013-11-27 12:11:31 +0800 | [diff] [blame] | 58 | |
| 59 | - To cross-compile Windows 64-bit binary, simply run |
Daniel Godas-Lopez | cf05e11 | 2013-11-28 18:23:39 +0000 | [diff] [blame] | 60 | $ ./compile.sh cross-win64 |
Nguyen Anh Quynh | 26ee41a | 2013-11-27 12:11:31 +0800 | [diff] [blame] | 61 | |
| 62 | Resulted files "capstone.dll" and "tests/test*.exe" can then be used on Windows machine. |
| 63 | |
| 64 | |
| 65 | |
Daniel Godas-Lopez | cf05e11 | 2013-11-28 18:23:39 +0000 | [diff] [blame] | 66 | (4) To compile under Cygwin gcc-mingw-w64-i686 or x86_64-w64-mingw32 run: |
| 67 | |
| 68 | - To compile Windows 32-bit binary under Cygwin, simply run |
| 69 | $ ./compile.sh cygwin-mingw32 |
| 70 | |
| 71 | - To compile Windows 64-bit binary under Cygwin, simply run |
| 72 | $ ./compile.sh cygwin-mingw64 |
| 73 | |
| 74 | |
Nguyen Anh Quynh | 2cd3370 | 2013-12-02 20:32:41 +0800 | [diff] [blame] | 75 | (5) 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] | 76 | |
Nguyen Anh Quynh | 46e8ca8 | 2013-11-28 10:10:50 +0800 | [diff] [blame] | 77 | $ ./compile.sh clang |
Nguyen Anh Quynh | 26ee41a | 2013-11-27 12:11:31 +0800 | [diff] [blame] | 78 | |
| 79 | |
Nguyen Anh Quynh | 676cabd | 2013-12-02 20:23:35 +0800 | [diff] [blame] | 80 | (6) So far, Python, Ruby, Ocaml, Java, C# and Go are supported by bindings. Look for |
| 81 | the bindings under directory bindings/, and refer to README file of corresponding languages. |
| 82 | |