www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - Can I compile for Linux from a Windows platform?

reply "Stephen Jones" <siwenjo gmail.com> writes:
Basically I want to develop a program on Windows and send the exe 
to someone to use on a Linux platform. Is this possible?
Oct 16 2013
parent reply "Jonathan M Davis" <jmdavisProg gmx.com> writes:
On Thursday, October 17, 2013 02:58:50 Stephen Jones wrote:
 Basically I want to develop a program on Windows and send the exe
 to someone to use on a Linux platform. Is this possible?
AFAIK, it's not possible. It _might_ be possible to do with mingw and gdc or ldc (I don't know if they use mingw or not, though I'd guess that they do), but even if you _could_ target Linux with that (which I doubt), the versions of the libraries the program was built against wouldn't match what would be found on a Linux box, so it wouldn't actually run on any Linux box. I've heard of building on Linux for mingw and then running it on Windows, but that's it, and I think that it's pretty surprising that that works. In general, you can't cross-compile across operating systems. - Jonathan M Davis
Oct 16 2013
parent reply "Adam D. Ruppe" <destructionator gmail.com> writes:
On Thursday, 17 October 2013 at 01:18:42 UTC, Jonathan M Davis 
wrote:
 In general, you can't cross-compile across operating systems.
Linux to Windows is pretty easy. You can just run the Windows version of dmd under wine on linux to make exes, or you can compile gcc (and presumably gdc, though I've never tried) for linux to make exes. I'm sure similar techniques could be used, in theory at least, to do Windows to Linux, but I've never seen it done.... and you're absolutely right about the versions not matching up. Hell, it is hard enough to get a binary from one linux box working on another linux box!
Oct 16 2013
next sibling parent "H. S. Teoh" <hsteoh quickfur.ath.cx> writes:
On Thu, Oct 17, 2013 at 04:24:07AM +0200, Adam D. Ruppe wrote:
 On Thursday, 17 October 2013 at 01:18:42 UTC, Jonathan M Davis
 wrote:
In general, you can't cross-compile across operating systems.
Linux to Windows is pretty easy. You can just run the Windows version of dmd under wine on linux to make exes, or you can compile gcc (and presumably gdc, though I've never tried) for linux to make exes. I'm sure similar techniques could be used, in theory at least, to do Windows to Linux, but I've never seen it done.... and you're absolutely right about the versions not matching up. Hell, it is hard enough to get a binary from one linux box working on another linux box!
Linux is rather heavy on the compile-from-source philosophy. Distributing binaries in Linux is fraught with peril and generally not done, except by distro vendors (who actually have a fighting chance of getting it right) and companies who are paranoid about distributing source (who generally *don't* get it right, thus are unable to reach a significant proportion of the Linux market). T -- Computers aren't intelligent; they only think they are.
Oct 16 2013
prev sibling parent Jerome BENOIT <g6299304p rezozer.net> writes:
If you want to play within a Linux environment on Windows, you can try CygWIN:
http://www.cygwin.com/

On 17/10/13 04:24, Adam D. Ruppe wrote:
 On Thursday, 17 October 2013 at 01:18:42 UTC, Jonathan M Davis wrote:
 In general, you can't cross-compile across operating systems.
Linux to Windows is pretty easy. You can just run the Windows version of dmd under wine on linux to make exes, or you can compile gcc (and presumably gdc, though I've never tried) for linux to make exes. I'm sure similar techniques could be used, in theory at least, to do Windows to Linux, but I've never seen it done.... and you're absolutely right about the versions not matching up. Hell, it is hard enough to get a binary from one linux box working on another linux box!
Oct 16 2013