www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - Is it possible to make an Linux Executable Binary using a Windows

reply 00004 <0 0.0> writes:
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.
Jul 24 2023
parent reply Guillaume Piolat <first.name gmail.com> writes:
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.
Jul 25 2023
parent Kagamin <spam here.lot> writes:
You will also need crt1.o, crti.o, crtn.o and libc.a
Jul 27 2023