简体   繁体   English

从 golang 为 iOS (armv7/arm64) 构建一个 c-shared dylib

[英]Build a c-shared dylib from golang for iOS (armv7/arm64)

Is there a way to build a dynamic library (dylib) from go code?有没有办法从 go 代码构建动态库(dylib)? I get it done for x86_64 and i386, but for arm64 and armv7(s) it says "buildmode=c-shared is not supported on darwin/arm".我为 x86_64 和 i386 完成了它,但对于 arm64 和 armv7(s),它说“darwin/arm 不支持 buildmode=c-shared”。 Why?为什么? Or is there a way to convert a static a-library file into a dynamically linked Mach-O dylib?或者有没有办法将 static a-library 文件转换为动态链接的 Mach-O dylib? I can merge the dylibs and a-files into one universal binary using lipo, but that still leaves them as static archives.我可以使用 lipo 将 dylib 和 a 文件合并到一个通用二进制文件中,但这仍然将它们保留为 static 档案。

I'm sure there must be a command to convert a static archive into a dynamic Mach-O library.我确信必须有一个命令将 static 存档转换为动态 Mach-O 库。 Any help appreciated, thank you!任何帮助表示赞赏,谢谢!

@Siguza gave me the correct hint. @Siguza 给了我正确的提示。 This is the final way to convert my static archive to a dynamic library for iOs - at least for arm64.这是将我的 static 存档转换为 iOs 的动态库的最终方法 - 至少对于 arm64。 I tried the same for armv7, but that lead to other issues and I decided to leave 32bit out here.我为 armv7 尝试了相同的方法,但这会导致其他问题,因此我决定将 32 位留在这里。

xcrun -sdk iphoneos clang -arch armv7 -fpic -shared -Wl,-all_load libmystatic.a -framework Corefoundation -o libmydynamic.dylib

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM