The Official Radare2 Book | страница 8
7. Log out of your Windows session.
8. Open up a new Windows Command Prompt: type cmd in the search bar. Ensure that the current path is not in the Radare2 folder.
9. Check Radare2 version from Command Prompt Window: radare2 -v
Radare2 can be cross-compiled for other architectures/systems as well, like Android.
Download the Android NDK from the official site and extract it somewhere on your system (e.g. /tmp/android-ndk)
$ echo NDK=/tmp/android-ndk > ~/.r2androidrc
./sys/android-build.sh arm64-static
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:
[binaries]
c = '/tmp/android-ndk/toolchains/llvm/prebuilt/linux-x86_64/bin/aarch64-linux-android28-clang'
cpp = '/tmp/android-ndk/toolchains/llvm/prebuilt/linux-x86_64/bin/aarch64-linux-android28-clang++'
ar = '/tmp/android-ndk/toolchains/llvm/prebuilt/linux-x86_64/bin/aarch64-linux-android-ar'
as = '/tmp/android-ndk/toolchains/llvm/prebuilt/linux-x86_64/bin/aarch64-linux-android-as'
ranlib = '/tmp/android-ndk/toolchains/llvm/prebuilt/linux-x86_64/bin/aarch64-linux-android-ranlib'
ld = '/tmp/android-ndk/toolchains/llvm/prebuilt/linux-x86_64/bin/aarch64-linux-android-ld'
strip = '/tmp/android-ndk/toolchains/llvm/prebuilt/linux-x86_64/bin/aarch64-linux-android-strip'
pkgconfig = 'false'
[properties]
sys_root = '/tmp/android-ndk/sysroot'
[host_machine]
system = 'android'
cpu_family = 'arm'
cpu = 'aarch64'
endian = 'little'
Now setup the build directory with meson as usual:
$
CFLAGS="-static" LDFLAGS="-static" meson --default-library static
--prefix=/tmp/android-dir -Dblob=true build --cross-file
./meson-android.ini
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.