blob: 6c63f9aa923f2f1c0501900f4d7f2ec436127391 [file] [log] [blame]
Nguyen Anh Quynha6a11532013-12-24 17:03:45 +08001How To Compile, install & run Capstone for Linux, Mac OSX, *nix and Windows
Nguyen Anh Quynh26ee41a2013-11-27 12:11:31 +08002 *-*-*-*-*-*
3
Nguyen Anh Quynh26ee41a2013-11-27 12:11:31 +08004Capstone requires no prerequisite packages, so it is easy to compile & install.
5
6
Nguyen Anh Quynh26ee41a2013-11-27 12:11:31 +08007
Nguyen Anh Quynha6a11532013-12-24 17:03:45 +08008(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 Quynh26ee41a2013-11-27 12:11:31 +080024 $ ./compile.sh
25 or:
26 $ make
27
Nguyen Anh Quynhb2dc0542013-12-09 16:05:49 +080028 For FreeBSD/OpenBSD, use 'gmake' instread of 'make':
Nguyen Anh Quynhf74bebf2013-12-09 13:53:11 +080029
30 $ gmake
31
Nguyen Anh Quynh26ee41a2013-11-27 12:11:31 +080032 Then run "./tests/test*" to see the tests disassembling sample code.
33
Nguyen Anh Quynha6a11532013-12-24 17:03:45 +080034 - On 64-bit OS, run command below to cross-compile Capstone for 32-bit binary:
Nguyen Anh Quynh26ee41a2013-11-27 12:11:31 +080035
36 $ ./compile.sh nix32
37
38 Then similarly, run "./tests/test*" to see the tests disassembling sample code.
39
40
41
Nguyen Anh Quynha6a11532013-12-24 17:03:45 +080042(2) Install Capstone on *nix
43
44 To install Capstone, run:
Nguyen Anh Quynh26ee41a2013-11-27 12:11:31 +080045
46 $ sudo make install
47
Nguyen Anh Quynhb2dc0542013-12-09 16:05:49 +080048 For FreeBSD/OpenBSD, use 'gmake' instead of 'make':
Nguyen Anh Quynhf74bebf2013-12-09 13:53:11 +080049
50 $ sudo gmake install
51
Nguyen Anh Quynha6a11532013-12-24 17:03:45 +080052 Users are then required to enter root password to copy Capstone into machine
53 system directories.
Nguyen Anh Quynh26ee41a2013-11-27 12:11:31 +080054
Nguyen Anh Quynha6a11532013-12-24 17:03:45 +080055 NOTE: The core framework that will be installed by "make install" consist of
56 only following files:
Nguyen Anh Quynh26ee41a2013-11-27 12:11:31 +080057
Patroklos Argyroudisa6503fe2013-11-27 14:25:34 +020058 /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 Quynh26ee41a2013-11-27 12:11:31 +080063 /usr/lib/libcapstone.so (for Linux/*nix), or /usr/lib/libcapstone.dylib (OSX)
Nguyen Anh Quynh04271222013-12-09 11:12:47 +080064 /usr/lib/libcapstone.a
Nguyen Anh Quynh26ee41a2013-11-27 12:11:31 +080065
66
67
Nguyen Anh Quynha6a11532013-12-24 17:03:45 +080068(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 Quynh26ee41a2013-11-27 12:11:31 +080072
73 - To cross-compile Windows 32-bit binary, simply run
Daniel Godas-Lopezcf05e112013-11-28 18:23:39 +000074 $ ./compile.sh cross-win32
Nguyen Anh Quynh26ee41a2013-11-27 12:11:31 +080075
76 - To cross-compile Windows 64-bit binary, simply run
Daniel Godas-Lopezcf05e112013-11-28 18:23:39 +000077 $ ./compile.sh cross-win64
Nguyen Anh Quynh26ee41a2013-11-27 12:11:31 +080078
Nguyen Anh Quynha6a11532013-12-24 17:03:45 +080079 Resulted files "capstone.dll" and "tests/test*.exe" can then be used on Windows machine.
Nguyen Anh Quynh26ee41a2013-11-27 12:11:31 +080080
81
82
Nguyen Anh Quynha6a11532013-12-24 17:03:45 +080083(4) Compile on Windows with Cygwin
84
85 To compile under Cygwin gcc-mingw-w64-i686 or x86_64-w64-mingw32 run:
Daniel Godas-Lopezcf05e112013-11-28 18:23:39 +000086
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 Quynha6a11532013-12-24 17:03:45 +080094
95(5) Compile with clang
96
97 By default, gcc is used as compiler. To use "clang" compiler instead, run command below:
Nguyen Anh Quynh26ee41a2013-11-27 12:11:31 +080098
Nguyen Anh Quynh46e8ca82013-11-28 10:10:50 +080099 $ ./compile.sh clang
Nguyen Anh Quynh26ee41a2013-11-27 12:11:31 +0800100
101
Nguyen Anh Quynh676cabd2013-12-02 20:23:35 +0800102
Nguyen Anh Quynha6a11532013-12-24 17:03:45 +0800103(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.