Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to compile the flex delegate c library for android #818

Open
CaptainDario opened this issue Feb 9, 2025 · 2 comments
Open

How to compile the flex delegate c library for android #818

CaptainDario opened this issue Feb 9, 2025 · 2 comments
Assignees
Labels
status:awaiting user response awaiting user response

Comments

@CaptainDario
Copy link

I am trying to compile the flex delegate c-library for android without success.
I tried various commands such as

bazelisk build -c opt --repo_env=HERMETIC_PYTHON_VERSION=3.11 --fat_apk_cpu=arm64-v8a //tensorflow/lite/delegates/flex:tensorflowlite_flex

bazelisk build -c opt --config=android_arm64  tensorflow/lite/delegates/flex:tensorflowlite_flex 

bazelisk build -c opt --config=android_arm --config=monolithic --define=TENSORFLOW_PROTOS=lite --verbose_failures //tensorflow/lite/delegates/flex:tensorflowlite_flex 

bazelisk build -c opt --config=android_arm64 --config=monolithic --define=tflite_convert_with_select_tf_ops=true --define=with_select_tf_ops=true //tensorflow/lite/delegates/flex:libtensorflowlite_flex.so

bazel build --config=android_arm64 \
    --cxxopt="-D__ANDROID__" \
    --copt="-DANDROID" \
    --copt="-D__ANDROID_API__=21" \
    --linkopt="-fuse-ld=lld" \
    --verbose_failures \
    //tensorflow/lite/delegates/flex:libtensorflowlite_flex.so \
    --monolithic

But all of them lead to

lite_rt_for_flutter_libs/tensorflow/tensorflow/lite/delegates/flex/BUILD:128:27: Linking tensorflow/lite/delegates/flex/libtensorflowlite_flex.so failed: (Exit 1): clang failed: error executing command (from target //tensorflow/lite/delegates/flex:libtensorflowlite_flex.so) external/androidndk/toolchains/llvm/prebuilt/darwin-x86_64/bin/clang @bazel-out/arm64-v8a-opt/bin/tensorflow/lite/delegates/flex/libtensorflowlite_flex.so-2.params
ld.lld: error: unknown argument '-framework'
ld.lld: error: cannot open CoreFoundation: No such file or directory
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Target //tensorflow/lite/delegates/flex:libtensorflowlite_flex.so failed to build
Use --verbose_failures to see the command lines of failed build steps.
INFO: Elapsed time: 853.521s, Critical Path: 176.99s
INFO: 2555 processes: 148 internal, 2407 local.
FAILED: Build did NOT complete successfully

I am trying to build on macos with m1 processor

Bazel version: 6.5.0
python version: 3.11

@gaikwadrahul8 gaikwadrahul8 self-assigned this Feb 10, 2025
@gaikwadrahul8
Copy link
Contributor

Hi, @CaptainDario
I apologize for the delayed response, If possible could you please help me with complete steps which you followed before encountering the mentioned error message and on which OS you're trying ?

I believe you are referencing the Build LiteRT for Android official documentation specifically the Set Up Build Environment without Docker section.

Thank you for your cooperation and understanding.

@gaikwadrahul8 gaikwadrahul8 added the status:awaiting user response awaiting user response label Feb 12, 2025
@CaptainDario
Copy link
Author

Thank you for your response!

Yes, I setup my build setup following the Build LiteRT for Android without docker.
Then I tried building the c share library (not Java), which resulted in the above error.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status:awaiting user response awaiting user response
Projects
None yet
Development

No branches or pull requests

2 participants