Cross Compile to Linux from Windows using LDC?

H. S. Teoh hsteoh at quickfur.ath.cx
Thu Feb 10 16:52:32 UTC 2022


On Thu, Feb 10, 2022 at 04:43:12PM +0000, Fry via Digitalmars-d-learn wrote:
> Is it possible to compile for Linux from Windows using the LDC
> compiler? It seems like it is possible to compile for different
> architectures Linux x86 -> Linux Arm but what about for Windows x86 ->
> Linux x86?

I'm not familiar with using LDC on Windows, but I imagine it should be
analogous to what I do for cross-compilation from Linux to Windows:

1) Download and unpack the Linux tarball for LDC.
2) Download and unpack the Windows zip file for LDC.
3) Edit ldc2.conf (for the Linux version of LDC) and add the following:

	"(i686|x86_64)-.*-windows.msvc":
	{
	    switches = [
		"-defaultlib=phobos2-ldc,druntime-ldc",
		"-link-defaultlib-shared=false",
	    ];
	    lib-dirs = [
		"/path/to/ldc2-1.28.1-windows-x64/lib",
	    ];
	};

4) Compile with `ldc -mtriple=x86_64-windows-msvc`.

If I understand it right, you ought to be able to do the same thing on
Windows by editing ldc2.conf for the Windows version of LDC and adding a
block for "i686-.*-linux-gnu" with the library paths set to point to the
Linux version of LDC, and compile with the appropriate -mtriple flag.


T

-- 
Spaghetti code may be tangly, but lasagna code is just cheesy.


More information about the Digitalmars-d-learn mailing list