www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.ldc - Cross compile linux -> OS X

reply Oleg B <code.viator gmail.com> writes:
Hello. It's possible to build application on linux for OS X? And 
if yes what I need to do for this? Also interesting works with 
libraries as gtk-d.
Nov 20
next sibling parent kinke <noone nowhere.com> writes:
On Monday, 20 November 2017 at 18:01:02 UTC, Oleg B wrote:
 Hello. It's possible to build application on linux for OS X? 
 And if yes what I need to do for this? Also interesting works 
 with libraries as gtk-d.
Hi Oleg, of course it's possible, I just don't know how much of a hassle it is. The steps are always the same: 1) Compile objects/static libs via `-mtriple=x86_64-darwin` (or a more specific triple, I'm not an Apple user). 2) Get ahold of druntime/Phobos for OSX; the simplest solution is to copy the libs from the official LDC package for OSX; compiling them yourself via the ldc-build-runtime tool (https://wiki.dlang.org/Building_LDC_runtime_libraries) would be another option but requires a full C cross-toolchain. 3) Link with a linker capable of outputting OSX binaries; you'll also need the OSX C runtime libs/init objects as druntime is built on top of the C runtime. I guess Apple doesn't provide a cross-toolchain by themselves, so you may have to copy the libs/objects over from an Xcode installation and link manually via LLD. Points 1 and 2 are trivial; point 3, cross-linking, is definitely the biggest hurdle. It's not specific to D though, so any guide/tutorial you find about how to cross-compile/link C(++) code from Linux to OSX will be applicable here as well.
Nov 20
prev sibling parent reply Jacob Carlborg <doob me.com> writes:
On 2017-11-20 19:01, Oleg B wrote:
 Hello. It's possible to build application on linux for OS X? And if yes 
 what I need to do for this? Also interesting works with libraries as gtk-d.
I have a Dockerfile for that [1]. Just invoke "ldc2" as usual, it's already configured to cross-compile. [1] https://github.com/jacob-carlborg/docker-ldc-darwin/blob/master/Dockerfile -- /Jacob Carlborg
Nov 21
parent Oleg B <code.viator gmail.com> writes:
On Tuesday, 21 November 2017 at 20:40:30 UTC, Jacob Carlborg 
wrote:
 On 2017-11-20 19:01, Oleg B wrote:
 Hello. It's possible to build application on linux for OS X? 
 And if yes what I need to do for this? Also interesting works 
 with libraries as gtk-d.
I have a Dockerfile for that [1]. Just invoke "ldc2" as usual, it's already configured to cross-compile. [1] https://github.com/jacob-carlborg/docker-ldc-darwin/blob/master/Dockerfile
Thanks! I try it near future.
Nov 23