←back to thread

228 points Retro_Dev | 1 comments | | HN request time: 0.22s | source
Show context
90s_dev ◴[] No.44464923[source]
I don't mind breaking changes if I can fix them within a day.

What bothers me with C/C++ is how difficult it is to cross compile a simple Windows + SDL app from inside WSL without MSVC installed.

I've spent weeks on this.

If Zig saves me from that nightmare, and still lets me use C++ libraries, I will gladly switch over to it.

replies(3): >>44464991 #>>44465628 #>>44472217 #
PaulDavisThe1st ◴[] No.44465628[source]
None of which has anything to do with C++ the language.
replies(3): >>44465762 #>>44466008 #>>44467927 #
flohofwoe ◴[] No.44466008[source]
That doesn't matter much when it's specifically the C/C++ compiler vendors who don't care about fixing the cross-compilation problem. It would be trivial for C/C++ compiler vendors to make cross-compilation as simple as with the Zig toolchain, but they don't care about the topic and that's why it doesn't happen.

Fast forward a few decades to today and the best solution to cross-compile C/C++ projects is the Zig toolchain (and isn't that kinda weird? A "foreign" toolchain coming along fixing one of the biggest problems in the C/C++ ecosystem just like that as a "side quest"?)

replies(2): >>44466584 #>>44466792 #
1. PaulDavisThe1st ◴[] No.44466584[source]
The problem with cross-compiling for Windows or macOS as targets are the runtimes (sometimes required during compilation or building), not the cross-compiling. This also has nothing to do with C/C++ as a language.

We build for Linux and Windows on Linux using gcc/mingw and don't have any fundamental issues doing so. On macOS we need the headers & libraries for macOS, we have to do those inside a VM.

I'd be extremely surprised if you can cross-compile Zig for macOS on a non-macOS platform, unless it doesn't use any macOS native frameworks at any level.