Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save lidgnulinux/eca51c04b1596790ab53694e4fd0436d to your computer and use it in GitHub Desktop.
Save lidgnulinux/eca51c04b1596790ab53694e4fd0436d to your computer and use it in GitHub Desktop.

Revisions

  1. lidgnulinux revised this gist Jun 18, 2025. 1 changed file with 5 additions and 5 deletions.
    10 changes: 5 additions & 5 deletions Build-static-android-platform-tools-without-go.md
    Original file line number Diff line number Diff line change
    @@ -11,13 +11,13 @@ Before we go deep into building stuffs, we need to prepare some stuffs.
    - 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.
    - fmt.
    - brotli, use `-DBUILD_SHARED_LIBS=OFF` option.
    - fmt, use `-DBUILD_SHARED_LIBS=OFF` option.
    - lz4.
    - protobuff.
    - zlib.
    - protobuff, use `-DBUILD_SHARED_LIBS=OFF` option.
    - zlib, use and add `--static` option when configure the build.
    - zstd.
    - libusb
    - libusb, use and add `--enable-static` option when configure the build.


    ## Steps
  2. lidgnulinux created this gist Jun 18, 2025.
    59 changes: 59 additions & 0 deletions Build-static-android-platform-tools-without-go.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,59 @@
    # Build Static Android Platform Tools without GO.

    Some days ago, I found an interesting [repository](https://github.com/nmeum/android-tools) about android tools which can be built without GO compiler (check it [here](https://github.com/nmeum/android-tools)). 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 !

    ## Preparations

    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.
    - fmt.
    - lz4.
    - protobuff.
    - zlib.
    - zstd.
    - libusb


    ## Steps

    These are some steps to build static android tools :

    1. Get the source code ! You can get it [here](https://github.com/nmeum/android-tools/releases/download/35.0.2/android-tools-35.0.2.tar.xz) for 35.0.2 version.
    1. 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")
    ```

    1. Do the regular build as the README suggest !


    ```
    $ mkdir build && cd build
    $ cmake ..
    $ make
    ```

    1. 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
    ```