cyber icon indicating copy to clipboard operation
cyber copied to clipboard

android build support

Open zhmt opened this issue 1 year ago • 6 comments

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 avatar Jul 22 '24 07:07 zhmt

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

zhmt avatar Jul 22 '24 12:07 zhmt

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.

fubark avatar Jul 22 '24 18:07 fubark

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

zhmt avatar Jul 22 '24 22:07 zhmt

what target should be used for IOS static library ?

calvin2021y avatar Jul 23 '24 06:07 calvin2021y

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

https://github.com/ziglang/zig/issues/19217 the targets are defined by zig lang. you can search in zig github.

zhmt avatar Jul 23 '24 08:07 zhmt

https://github.com/ziglang/zig/issues/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.

zhmt avatar Jul 23 '24 08:07 zhmt