Thread overview
Is it possible to make an Linux Executable Binary using a Windows Operating System? [compiling and linking]
Jul 24
00004
Jul 28
Kagamin
July 24

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.

July 25

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.

July 28

You will also need crt1.o, crti.o, crtn.o and libc.a