Autopatchelfhook: libc++ not found for zipalign

I am trying to patch elf of android-tools zipalign, and it isn’t working because libc++ not found

What I have tried

  • adding libgcc, libcxx, llvmPackages_19.libcxx and llvmPackages_19.libcxxClang to buildInputs

  • adding pkg-config to nativeBuildInputs

I got the solution from reddit. credit: u/TuvoksSon

buildInputs = [ pkgs.libcxx ... ];
preFixup = ''
  patchelf --replace-needed libc++.so libc++.so.1 $out/bin/zipalign
  patchelf --add-needed libc++abi.so.1 $out/bin/zipalign
'';

The explanation for why this works can be found in the reddit comment