Compilation on Android
最后更新于
这有帮助吗?
最后更新于
这有帮助吗?
Radare2 can be cross-compiled for other architectures/systems as well, like Android.
Python 3
Meson
Ninja
Git
Android NDK
Download the Android NDK from the and extract it somewhere on your system (e.g. /tmp/android-ndk
)
You can build for different architectures by changing the argument to ./sys/android-build.sh
. Run the script without any argument to see the accepted values.
Meson needs a configuration file that describes the cross compilation environment (e.g. meson-android.ini
). You can adjust it as necessary, but something like the following should be a good starting point:
Now setup the build directory with meson as usual:
A bit of explanation about all the options:
CFLAGS="-static"
, LDFLAGS="-static"
, --default-library static
: this
ensure that libraries and binaries are statically compiled, so you do not need
to properly set LD_* environment variables in your Android environment to make
it find the right libraries. Binaries have everything they need inside.
-Dblob=true
: it tells meson to compile just one binary with all the needed
code for running radare2
, rabin2
, rasm2
, etc. and creates symbolic links to
those names. This avoids creating many statically compiled large binaries and
just create one that provides all features. You will still have rabin2
,
rasm2
, rax2
, etc. but they are just symlinks to radare2
.
--cross-file ./meson-android.ini
: it describes how to compile radare2 for Android
Then compile and install the project:
At this point you can copy the generated files in /tmp/android-dir to your Android device and running radare2 from it. For example: