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

android build support #94

Open
zhmt opened this issue Jul 22, 2024 · 6 comments
Open

android build support #94

zhmt opened this issue Jul 22, 2024 · 6 comments

Comments

@zhmt
Copy link

zhmt commented Jul 22, 2024

Hi , I am trying to embed it into my android game (a c++ project), will you please add cross build for android? static and shared, debug and release options?
I am not farmiliar with zig.
But I have built a "libcyber.a" static libary succsussfully.

It encounted some errors, and it fixed by modifing the build.zig. Maybe you guys will do better. Here is my building command:
zig build lib -Doptimize=ReleaseFast -Dtarget=aarch64-linux-android

The modifed build.zig is attached, just focus on lines including "addIncludePath(.{ .path = "D:/Prog/Android.....".

I will be happy if android building is supported. Thank you.
build.zig.txt

@zhmt
Copy link
Author

zhmt commented Jul 22, 2024

Failed to build shared library. with eorrors:

 zig build lib -Doptimize=ReleaseFast -Dtarget=aarch64-linux-android  -Dstatic=false

lib
+- install cyber
   +- zig build-lib cyber ReleaseFast aarch64-linux-android 1 errors
error: libc not available
    note: run 'zig libc -h' to learn about libc installations
    note: run 'zig targets' to see the targets for which zig can always provide libc

@fubark
Copy link
Owner

fubark commented Jul 22, 2024

I can confirm that the c-embedded/main.c is working with static library build using zig build lib -Doptimize=ReleaseFast -Dtarget=aarch64-linux-android. Dynamic library builds should be avoided.

I'm against releasing large debug artifacts, but we can add a Release artifact for aarch64-linux-android in the near term and add tests later, and I can also attach an example Android NDK project.

Edit: Well this is awkward, I have included an example project but it requires a patch to Zig 0.12.0, see the README. I would have upgraded to 0.13.0 but that version introduces miscompilation for packed structs. So far now we are stuck on 0.12.0 and will have to hold off on a Android release artifact.

@zhmt
Copy link
Author

zhmt commented Jul 22, 2024

Thanks for your response, I downloaded the source from master, It works well. Let me try linking to the static library.

@calvin2021y
Copy link

what target should be used for IOS static library ?

@zhmt
Copy link
Author

zhmt commented Jul 23, 2024

what target should be used for IOS static library ?
aarch64-ios

ziglang/zig#19217
the targets are defined by zig lang. you can search in zig github.

@zhmt
Copy link
Author

zhmt commented Jul 23, 2024

ziglang/zig#17575
I got this error now, difficult to figure out.
zig building is too buggy now, maybe I should try it a few days later.
Thanks for your help, @fubark.

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

No branches or pull requests

3 participants