Giter VIP home page Giter VIP logo

Comments (2)

lzhiyong avatar lzhiyong commented on June 15, 2024

I have managed to use termux-ndk(openjdk-11.0.1 ndk-r21 android-sdk(build-tools:29.0.3 platforms:android-29)) to build a project(without gradle).
Here's some problems I encountered. I think the host API level of the prebuilt JDK, NDK and SDK need to be presented.

1)Firstly I tried to build my project on a Android 8.1 device. The compilation was fine, but there was an error during linking, saying:

CANNOT LINK EXECUTABLE "/data/data/com.termux/files/home/android-ndk-r21/toolchains/llvm/prebuilt/linux-aarch64/bin/../lib/gcc/aarch64-linux-android/4.9.x/../../../../aarch64-linux-android/bin/ld": cannot locate symbol "glob" referenced by "/data/data/com.termux/files/home/android-ndk-r21/toolchains/aarch64-linux-android-4.9/prebuilt/linux-aarch64/bin/aarch64-linux-android-ld"...

Which I think is caused by lacking "glob" function in libc.so.
I have searched the web and found something saying glob was added to Bionic on API Level 28 (Android 9). Termux now targets API Level 24 (Android 7.0) and includes a compatibility library libandroid-glob.

https://github.com/android/ndk/issues/126
https://github.com/termux/termux-packages/tree/master/packages/libandroid-glob

2)Then I switched to a Android 10 device and encountered a error during static library build, saying:

CANNOT LINK EXECUTABLE "/data/data/com.termux/files/home/android-ndk-r21/toolchains/llvm/prebuilt/linux-aarch64/bin/llvm-ar": library "libc++_shared.so" not found

I found android-ndk-r21/toolchains/llvm/prebuilt/linux-aarch64/lib64/libc++.so.1 is the library that references libc++_shared.so. But I checked its import functions and found it doesn't import any functions from libc++_shared.so. I think there may be a problem with its build process. Anyway, I copied libc++_shared.so from <NDK_PATH>\toolchains\llvm\prebuilt\windows-x86_64\sysroot\usr\lib\aarch64-linux-android\libc++_shared.so on my Windows machine and it works.

3)The third problem is trivial and it is in d8 tool, which relies 'java' in PATH environment variable.

/data/data/com.termux/files/home/android-sdk/build-tools/29.0.3/d8: line 89: exec: java: not found

I fixed it by add a symbol link, and I think it's better documented in the readme.

ln -s /data/data/com.termux/files/home/openjdk-11.0.1/bin/java /data/data/com.termux/files/usr/bin/java

I haven't tested the build of the project without gradle,so there may be some problems, thank you for your reply, the next version of r22 may test and fix these problems!

from termux-ndk.

IanusInferus avatar IanusInferus commented on June 15, 2024

By the way, I have patched aarch64-linux-android-ld and libc++.so.1 with patchelf and it works great without problem on my Android 8.1 and 10.0 devices.

./patchelf --add-needed libandroid-glob.so aarch64-linux-android-ld
./patchelf --remove-needed libc++_shared.so libc++.so.1

from termux-ndk.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.