blob: 0825858499c614903721be70d73a32c18ef969ab [file] [log] [blame]
Nguyen Anh Quynhb8f2af62013-12-25 10:49:59 +08001How To Compile, install & run Capstone for Linux, Mac OSX, *BSD 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
Oliver Pinter6e2c0752014-01-16 12:16:21 +010031 or:
32 $ ./compile.sh bsd
Nguyen Anh Quynhf74bebf2013-12-09 13:53:11 +080033
Nguyen Anh Quynh26ee41a2013-11-27 12:11:31 +080034 Then run "./tests/test*" to see the tests disassembling sample code.
35
Nguyen Anh Quynha6a11532013-12-24 17:03:45 +080036 - On 64-bit OS, run command below to cross-compile Capstone for 32-bit binary:
Nguyen Anh Quynh26ee41a2013-11-27 12:11:31 +080037
38 $ ./compile.sh nix32
39
40 Then similarly, run "./tests/test*" to see the tests disassembling sample code.
41
42
43
Nguyen Anh Quynha6a11532013-12-24 17:03:45 +080044(2) Install Capstone on *nix
45
46 To install Capstone, run:
Nguyen Anh Quynh26ee41a2013-11-27 12:11:31 +080047
48 $ sudo make install
49
Nguyen Anh Quynhb2dc0542013-12-09 16:05:49 +080050 For FreeBSD/OpenBSD, use 'gmake' instead of 'make':
Nguyen Anh Quynhf74bebf2013-12-09 13:53:11 +080051
52 $ sudo gmake install
53
Nguyen Anh Quynha6a11532013-12-24 17:03:45 +080054 Users are then required to enter root password to copy Capstone into machine
55 system directories.
Nguyen Anh Quynh26ee41a2013-11-27 12:11:31 +080056
Nguyen Anh Quynha6a11532013-12-24 17:03:45 +080057 NOTE: The core framework that will be installed by "make install" consist of
58 only following files:
Nguyen Anh Quynh26ee41a2013-11-27 12:11:31 +080059
Patroklos Argyroudisa6503fe2013-11-27 14:25:34 +020060 /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 Quynh26ee41a2013-11-27 12:11:31 +080065 /usr/lib/libcapstone.so (for Linux/*nix), or /usr/lib/libcapstone.dylib (OSX)
Nguyen Anh Quynh04271222013-12-09 11:12:47 +080066 /usr/lib/libcapstone.a
Nguyen Anh Quynh26ee41a2013-11-27 12:11:31 +080067
68
69
Nguyen Anh Quynha6a11532013-12-24 17:03:45 +080070(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 Quynh26ee41a2013-11-27 12:11:31 +080074
75 - To cross-compile Windows 32-bit binary, simply run
Daniel Godas-Lopezcf05e112013-11-28 18:23:39 +000076 $ ./compile.sh cross-win32
Nguyen Anh Quynh26ee41a2013-11-27 12:11:31 +080077
78 - To cross-compile Windows 64-bit binary, simply run
Daniel Godas-Lopezcf05e112013-11-28 18:23:39 +000079 $ ./compile.sh cross-win64
Nguyen Anh Quynh26ee41a2013-11-27 12:11:31 +080080
Nguyen Anh Quynha6a11532013-12-24 17:03:45 +080081 Resulted files "capstone.dll" and "tests/test*.exe" can then be used on Windows machine.
Nguyen Anh Quynh26ee41a2013-11-27 12:11:31 +080082
83
84
Nguyen Anh Quynha6a11532013-12-24 17:03:45 +080085(4) Compile on Windows with Cygwin
86
87 To compile under Cygwin gcc-mingw-w64-i686 or x86_64-w64-mingw32 run:
Daniel Godas-Lopezcf05e112013-11-28 18:23:39 +000088
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 Pinter6e2c0752014-01-16 12:16:21 +010096(5) By default, cc (default c compiler on the system) is used as compiler.
Nguyen Anh Quynha6a11532013-12-24 17:03:45 +080097
Oliver Pinter6e2c0752014-01-16 12:16:21 +010098 - To use "clang" compiler instead, run command below:
Nguyen Anh Quynha6a11532013-12-24 17:03:45 +080099
Oliver Pinter6e2c0752014-01-16 12:16:21 +0100100 $ ./compile.sh clang
Nguyen Anh Quynh26ee41a2013-11-27 12:11:31 +0800101
Oliver Pinter6e2c0752014-01-16 12:16:21 +0100102 - To use "gcc" compiler instead, run this command:
103
104 $ ./compile.sh gcc
105
Nguyen Anh Quynh26ee41a2013-11-27 12:11:31 +0800106
107
Nguyen Anh Quynh676cabd2013-12-02 20:23:35 +0800108
Nguyen Anh Quynha6a11532013-12-24 17:03:45 +0800109(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.