Debian Codegraph @

COMPILE.TXT

raw
1 This documentation explains how to compile, install & run Capstone on MacOSX,
2 Linux, *BSD & Solaris. We also show steps to cross-compile for Microsoft Windows.
3
4 To natively compile for Windows using Microsoft Visual Studio, see COMPILE_MSVC.TXT.
5
6 To compile using CMake, see COMPILE_CMAKE.TXT.
7
8 To compile using XCode on MacOSX, see xcode/README.md.
9
10 To compile for Windows CE (a.k.a, Windows Embedded Compact), see windowsce/COMPILE.md.
11
12 *-*-*-*-*-*
13
14 Capstone requires no prerequisite packages, so it is easy to compile & install.
15
16
17
18 (0) Tailor Capstone to your need.
19
20 Out of all archtitectures supported by Capstone, if you just need several
21 selected archs, choose the ones you want to compile in by editing "config.mk"
22 before going to next steps.
23
24 By default, all architectures are compiled.
25
26 The other way of customize Capstone without having to edit config.mk is to
27 pass the desired options on the commandline to ./make.sh. Currently,
28 Capstone supports 8 options, as followings.
29
30 - CAPSTONE_ARCHS: specify list of architectures to compiled in.
31 - CAPSTONE_USE_SYS_DYN_MEM: change this if you have your own dynamic memory management.
32 - CAPSTONE_DIET: use this to make the output binaries more compact.
33 - CAPSTONE_X86_REDUCE: another option to make X86 binary smaller.
34 - CAPSTONE_X86_ATT_DISABLE: disables AT&T syntax on x86.
35 - CAPSTONE_STATIC: build static library.
36 - CAPSTONE_SHARED: build dynamic (shared) library.
37 - CAPSTONE_DEBUG: enable debug build supporting assert().
38
39 By default, Capstone uses system dynamic memory management, both DIET and X86_REDUCE
40 modes are disable, and builds all the static & shared libraries.
41
42 To avoid editing config.mk for these customization, we can pass their values to
43 make.sh, as followings.
44
45 $ CAPSTONE_ARCHS="arm aarch64 x86" CAPSTONE_USE_SYS_DYN_MEM=no CAPSTONE_DIET=yes CAPSTONE_X86_REDUCE=yes ./make.sh
46
47 NOTE: on commandline, put these values in front of ./make.sh, not after it.
48
49 For each option, refer to docs/README for more details.
50
51
52
53 (1) Compile from source
54
55 On *nix (such as MacOSX, Linux, *BSD, Solaris):
56
57 - To compile for current platform, run:
58
59 $ ./make.sh
60
61 - On 64-bit OS, run the command below to cross-compile Capstone for 32-bit binary:
62
63 $ ./make.sh nix32
64
65
66
67 (2) Install Capstone on *nix
68
69 To install Capstone, run:
70
71 $ sudo ./make.sh install
72
73 For FreeBSD/OpenBSD, where sudo is unavailable, run:
74
75 $ su; ./make.sh install
76
77 Users are then required to enter root password to copy Capstone into machine
78 system directories.
79
80 Afterwards, run ./tests/test* to see the tests disassembling sample code.
81
82
83 NOTE: The core framework installed by "./make.sh install" consist of
84 following files:
85
86 /usr/include/capstone/arm.h
87 /usr/include/capstone/arm64.h
88 /usr/include/capstone/bpf.h
89 /usr/include/capstone/capstone.h
90 /usr/include/capstone/evm.h
91 /usr/include/capstone/m680x.h
92 /usr/include/capstone/m68k.h
93 /usr/include/capstone/mips.h
94 /usr/include/capstone/mos65xx.h
95 /usr/include/capstone/platform.h
96 /usr/include/capstone/ppc.h
97 /usr/include/capstone/sparc.h
98 /usr/include/capstone/systemz.h
99 /usr/include/capstone/tms320c64x.h
100 /usr/include/capstone/wasm.h
101 /usr/include/capstone/x86.h
102 /usr/include/capstone/xcore.h
103 /usr/include/capstone/tricore.h
104 /usr/lib/libcapstone.a
105 /usr/lib/libcapstone.so (for Linux/*nix), or /usr/lib/libcapstone.dylib (OSX)
106
107
108
109 (3) Cross-compile for Windows from *nix
110
111 To cross-compile for Windows, Linux & gcc-mingw-w64-i686 (and also gcc-mingw-w64-x86-64
112 for 64-bit binaries) are required.
113
114 - To cross-compile Windows 32-bit binary, simply run:
115
116 $ ./make.sh cross-win32
117
118 - To cross-compile Windows 64-bit binary, run:
119
120 $ ./make.sh cross-win64
121
122 Resulted files libcapstone.dll, libcapstone.dll.a & tests/test*.exe can then
123 be used on Windows machine.
124
125
126
127 (4) Cross-compile for iOS from Mac OSX.
128
129 To cross-compile for iOS (iPhone/iPad/iPod), Mac OSX with XCode installed is required.
130
131 - To cross-compile for ArmV7 (iPod 4, iPad 1/2/3, iPhone4, iPhone4S), run:
132 $ ./make.sh ios_armv7
133
134 - To cross-compile for ArmV7s (iPad 4, iPhone 5C, iPad mini), run:
135 $ ./make.sh ios_armv7s
136
137 - To cross-compile for Arm64 (iPhone 5S, iPad mini Retina, iPad Air), run:
138 $ ./make.sh ios_arm64
139
140 - To cross-compile for all iDevices (armv7 + armv7s + arm64), run:
141 $ ./make.sh ios
142
143 Resulted files libcapstone.dylib, libcapstone.a & tests/test* can then
144 be used on iOS devices.
145
146
147
148 (5) Cross-compile for Android
149
150 To cross-compile for Android (smartphone/tablet), Android NDK is required.
151 NOTE: Only ARM and ARM64 are currently supported.
152
153 $ NDK=/android/android-ndk-r10e ./make.sh cross-android arm
154 or
155 $ NDK=/android/android-ndk-r10e ./make.sh cross-android arm64
156
157 Resulted files libcapstone.so, libcapstone.a & tests/test* can then
158 be used on Android devices.
159
160
161
162 (6) Compile on Windows with Cygwin
163
164 To compile under Cygwin gcc-mingw-w64-i686 or x86_64-w64-mingw32 run:
165
166 - To compile Windows 32-bit binary under Cygwin, run:
167
168 $ ./make.sh cygwin-mingw32
169
170 - To compile Windows 64-bit binary under Cygwin, run:
171
172 $ ./make.sh cygwin-mingw64
173
174 Resulted files libcapstone.dll, libcapstone.dll.a & tests/test*.exe can then
175 be used on Windows machine.
176
177
178
179 (7) By default, "cc" (default C compiler on the system) is used as compiler.
180
181 - To use "clang" compiler instead, run the command below:
182
183 $ ./make.sh clang
184
185 - To use "gcc" compiler instead, run:
186
187 $ ./make.sh gcc
188
189
190
191 (8) To uninstall Capstone, run the command below:
192
193 $ sudo ./make.sh uninstall
194
195
196
197 (9) Language bindings
198
199 So far, Python, Ocaml & Java are supported by bindings in the main code.
200 Look for the bindings under directory bindings/, and refer to README file
201 of corresponding languages.
202
203 Community also provide bindings for C#, Go, Ruby, NodeJS, C++ & Vala. Links to
204 these can be found at address http://capstone-engine.org/download.html