Is it possible to make an Linux Executable Binary using a Windows Operating System? [compiling and linking]

Guillaume Piolat first.name at gmail.com
Tue Jul 25 12:06:22 UTC 2023


On Monday, 24 July 2023 at 11:57:11 UTC, 00004 wrote:
> Could someone share a step by step way to compile and link a 
> x86-64 Linux Binary using Windows 10? (Without virtual machine 
> or "Linux Subsystem for Windows")
>
> I want to compile and link a Hello World program for both Linux 
> and Windows.
>
> **example.d**
> ```
> import std.stdio;
>
> void main()
> {
>     writeln("Hello, World!");
> }
> ```
>
> So I need `.exe` binary for windows
> and a runnable linux binary for linux.

1. Download LDC for Linux x86-64 and LDC for Windows
2. In your LDC that you want to use as cross-compiler, edit 
etc/ldc2.conf to add the triple entry from the other LDC, for 
linux cross-compiler support
3. Copy the pre-compiles libraries from the Linux LDC so that 
they are accessible from your cross-compiler.
4. Use DUB with the right triple eg.
   $ dub -a x86_64-something-linux

   If DUB finds your cross-compiler, it will pass the triple to 
-mtriple.


More information about the Digitalmars-d-learn mailing list