i actually tried making a linux x86-64 hello world ELF with just imhex the other day as a challenge. it's a lot easier than you might expect, i managed to get a well-formed and functional program in just 400 bytes using only the wikipedia article on ELF and an x86-64 reference sheet
Using mingw. It's also great for compatibility - not needing to create so much #ifdef __windows__, or basically a second codebase due to differing syscalls, methods, and standards. You still need to use a good amount of #ifdef __insert os__, but mingw does make it simpler to do.
Never had to really compiled to windows exe from Linux, but I have coded on Windows (for school), and aftering trying to debug compile errors, I realized the code/functions I wrote based upon tutorials only compile in Linux because it just be like that fking somehow.
mingw is great but I use it to cross compile apps for Windows on Linux. My comment was about it being a lot more pain in the ass to compile Linux apps on Windows (without WSL, of course)
My question is, why? It's so much easier to compile Linux apps on Linux, and it wasn't that hard to get yourself a Linux system even before WSL (make a VM, or grab a laptop, or something).
Cross-compilation is always painful no matter the system, but for me I use mingw(and gcc of course) because I can use my Linux host to compile for multiple platforms (Linux, Windows, macOS and Android)
Yeah. The pain of cross-compilation makes it often easier to grab an actual system of the target variety to do your building - which is a pain for some systems, but much less so for Linux. That's why I expect to hear much more about "it's so annoying trying to build a Windows binary on Linux" than "it's so annoying trying to build a Linux binary on Windows".
It's actually not really that painful if you create a docker container for everything you want to build to. This will work for linux/aarch64/mingw. It starts getting painful when you support something like armv6 (Raspberry Pi Zero W) because you need a sysroot... and there are multiple layers that can mess up. In your case MacOS and Anroid would be toughest. MacOS not really being worth it due to licensing.
msvc and link.exe in visual studio can create efi applications directly btw for a uefi library just pull gnu-efi, build the visual studio project and link that
8
u/centixog Sep 04 '26 edited Sep 04 '26
cross compatability is jungle of solutions.
i recall monodevelop was good for this but using a CIL comes at a cost.
ah right its a programming joke sub.
what did the ubuntu compiler say to the cpu?
make me a binary and in a snap(pack)!
198
u/Makonede Sep 04 '26
actual programmer humor? in my llm slop subreddit? it's more likely than you think
41
u/Pball1001 Sep 04 '26
What are you compiling for? Just write the object code yourself and link it up too
26
u/Time-Worker9846 Sep 03 '26
It's a lot easier the other way
10
u/an_0w1 Sep 04 '26
Isn't this super simple with clang?
2
u/AndyTheDragonborn Sep 04 '26
Thy must make a sacrifice for the compiled code to even be recognized, way before you can even hope to have permission to execute it
2
u/Sermuns Sep 04 '26
Use Rust.
1
u/Compizfox Sep 04 '26
Why tho?
1
u/Kayo4life Sep 04 '26
u/savevideobot
1
u/Helpful-Primary2427 Sep 04 '26
GCC can’t cross compile windows -> Linux? Idk I use Mac and clang
1
u/Leo0806-studios Sep 04 '26
msvc and link.exe in visual studio can create efi applications directly btw
for a uefi library just pull gnu-efi, build the visual studio project and link that