Some days ago, I found an interesting repository about android tools which can be built without GO compiler (check it here). If you're familiar with adb
, fastboot
, etc, you know what I'm talking about. It suits me because I have no GO compiler or won't bother to download one because I already have GCC. After firts successful build which result on dynamic linked binaries, I'm curious on building the static linked one. Here is how I did it !
Before we go deep into building stuffs, we need to prepare some stuffs.
-
Make sure you have GCC / Clang !
-
Satisfy the dependencies, check on the README !
-
Make sure you rebuild these package and enable their static option ! Be careful, some these libs will probably mess your system if you don't know what you're doing !
- abseil-cpp.
- brotli, use
-DBUILD_SHARED_LIBS=OFF
option. - fmt, use
-DBUILD_SHARED_LIBS=OFF
option. - lz4.
- protobuff, use
-DBUILD_SHARED_LIBS=OFF
option. - zlib, use and add
--static
option when configure the build. - zstd.
- libusb, use and add
--enable-static
option when configure the build.
These are some steps to build static android tools :
-
Get the source code ! You can get it here for 35.0.2 version.
-
Modify the CmakeLists.txt file ! Add these line after line contain
project(android-tools)
!set(BUILD_SHARED_LIBS OFF) set(CMAKE_FIND_LIBRARY_SUFFIXES ".a") set(CMAKE_EXE_LINKER_FLAGS "-static")
-
Do the regular build as the README suggest !
$ mkdir build && cd build $ cmake .. $ make
-
Check if resulted executables are static linked, you can check at build/vendor directory !
$ cd .. $ file build/vendor/adb # adb, for example
You should get this line :
build/vendor/adb: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), statically linked, with debug_info, not stripped