5 ms·
Cross compiling with zig is so easy. For example I use sqlite in Go projects on arm. The incantation is just: export GOARCH=arm64 export CC=zig cc -tar
by psanford 4y ago
Cross compiling with zig is so easy. For example I use sqlite in Go projects on arm. The incantation is just:
export GOARCH=arm64
export CC=zig cc -target aarch64-linux-musl
export CXX=zig cc -target aarch64-linux-musl
- pjmlp 4y agoCross compilation is always easy when there are no dependencies to the target platform SDKs. When it goes beyond basic libc stuff, then it is when the fun starts.
- 10000truths 4y agoIt seems fairly straightforward - copy over the SDK header files and libraries to the project and then add these envs to the build: CC="/path/to/cross/compiler" CGO_CFLAGS=—I/path/to/sdk/header/files/include" CGO_LDFLAGS="-L/path/to/sdk/obj/files/lib” I suppose with .so files, you might have to specify "-Wl,-rpath" if the SDK libraries don’t reside under /usr/lib or /usr/local/lib on the target system. But I haven’t actually tried any of this yet, so I could be wrong. Are there any gotchas that I’m missing?
- pjmlp 4y agoNow do the same as Windows UWP SDK, or iOS SDK. You're missing all the tooling and OS specific steps required to produce a proper package.
- shepherdjerred 4y agoFor macOS: https://github.com/tpoechtrager/osxcross https://github.com/tpoechtrager/osxcross
- pjmlp 4y agoDoesn't seem to do IO Kit, DriverKit, Metal, Instruments Plugins, UI frameworks, XPC, and plenty of other stuff dependent on Objective-C/Swift.
- shepherdjerred 4y agoI believe it would work for all of that, given that it links to the same libraries an app made with Xcode would. That repository won't compile Swift, but it does compile objective C. Either way, you don't need to be able to compile Swift/Obj C to link to a library that was written in Swift/Obj C.