64-bit compilation in Wine

H. S. Teoh hsteoh at quickfur.ath.cx
Tue Dec 29 20:29:15 UTC 2020


On Tue, Dec 29, 2020 at 07:39:14PM +0000, Raikia via Digitalmars-d-learn wrote:
[...]
> So interestingly, I actually got this to work by running "sudo wine"
> instead of just "wine".  No idea why wine needs root access on the
> underlying system for wine to operate properly but ok...
> 
> Now I'm running into an issue of not having libcmt in Wine so it
> dynamically links to msvcrt instead (and thus requires a dll on
> deployment).  Have you come across this before?

Haven't come across this myself, but I'd mention that if what you're
interested in is to cross-compile from Posix to Windows, you should
really consider using LDC instead, which has cross-compilation built-in,
and the Windows version comes bundled with all the necessary libraries
to compile and link a runnable executable without needing to download
additional libraries (unless your own code uses additional libraries).

Some time ago I wanted to compile a Linux app for Windows user, so I
tried using Wine with the Windows version of DMD.  It worked, but it was
klunky, and prone to breakages like the ones you describe.  Eventually,
I gave up and used LDC instead, and it's been working very well.  Here's
my setup:

1) Install LDC, Linux version. Let's say for illustration purposes this
is in /usr/local/ldc/linux.

2) Download and unpack LDC, Windows version. Let's say you put this in
/usr/local/ldc/windows.

3) Edit ldc2.conf for the Linux version (probably in
/usr/local/ldc/linux/etc/ldc2.conf), and add this block to the bottom of
the file, so that LDC will find the right Windows libraries to link to:

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

4) Compile your program with:

	ldc2 -mtriple=x86_64-windows-msvc ... # rest of flags, files, etc.

This produces a Windows executable that you can run directly on Windows
(or even in Wine) without any additional hassles.


T

-- 
Life would be easier if I had the source code. -- YHL


More information about the Digitalmars-d-learn mailing list