digitalmars.D.ldc - cross compiling os x -> linux
- yawniek (12/12) Mar 29 2016 is it possible to cross compile linux binaries from os x?
- kinke (8/10) Mar 29 2016 I haven't tried it myself yet, but what you'd need to output an
- Jacob Carlborg (9/19) Mar 29 2016 Yes. I tried using the ellcc cross compiler [1], which contains the
- Kai Nacke (10/22) Mar 29 2016 Hi yawniek!
- Joakim (18/30) Mar 30 2016 Yes and no, ldc is a very good cross-compiler and will work for
- Joakim (6/12) Mar 30 2016 Btw, this would be very easy to do with the just announced
is it possible to cross compile linux binaries from os x? or in other words, is there a tutorial on how to build such a toolchain? what i tried: ldc2 -of test -mtriple=i686-unknown-linux-gnu -relocation-model=pic test.d ld: library not found for -lrt clang: error: linker command failed with exit code 1 (use -v to see invocation) Error: /usr/bin/gcc failed with status: 1 so i guess i need a directory with all my linux libraries and the correct parameters?!
Mar 29 2016
On Tuesday, 29 March 2016 at 10:59:41 UTC, yawniek wrote:so i guess i need a directory with all my linux libraries and the correct parameters?!I haven't tried it myself yet, but what you'd need to output an executable or a library directly are of couse the target (Linux) libraries and a compatible cross-linker. That sounds like too much hassle for me, so I'd only output the object files (-c) for a cross-compile, and then copy them over to a Linux box/VM to perform the linking directly there on the target with its native toolchain.
Mar 29 2016
On 2016-03-29 12:59, yawniek wrote:is it possible to cross compile linux binaries from os x? or in other words, is there a tutorial on how to build such a toolchain? what i tried: ldc2 -of test -mtriple=i686-unknown-linux-gnu -relocation-model=pic test.d ld: library not found for -lrt clang: error: linker command failed with exit code 1 (use -v to see invocation) Error: /usr/bin/gcc failed with status: 1 so i guess i need a directory with all my linux libraries and the correct parameters?!Yes. I tried using the ellcc cross compiler [1], which contains the linker and similar necessary tools for all targets it supports. Unfortunately I got errors of missing symbols related to backgrace: undefined reference to `backtrace_symbols_fd' undefined reference to `backtrace_symbols' [1] http://ellcc.org -- /Jacob Carlborg
Mar 29 2016
On Tuesday, 29 March 2016 at 10:59:41 UTC, yawniek wrote:is it possible to cross compile linux binaries from os x? or in other words, is there a tutorial on how to build such a toolchain? what i tried: ldc2 -of test -mtriple=i686-unknown-linux-gnu -relocation-model=pic test.d ld: library not found for -lrt clang: error: linker command failed with exit code 1 (use -v to see invocation) Error: /usr/bin/gcc failed with status: 1 so i guess i need a directory with all my linux libraries and the correct parameters?!Hi yawniek! A description how to cross-compile can be found here: http://forum.dlang.org/post/fhwvxatxezkafnalwhqr forum.dlang.org. For sure to build a linux binary you need all the referenced libs. I can't give you advice on how to build such an environment on OS X. Linux distributions usually provide some cross-compilers and libraries. Maybe you find a brew package. Regards, Kai
Mar 29 2016
On Tuesday, 29 March 2016 at 10:59:41 UTC, yawniek wrote:is it possible to cross compile linux binaries from os x?Yes and no, ldc is a very good cross-compiler and will work for that purpose most of the time: unfortunately it cannot link those binaries yet. ;)or in other words, is there a tutorial on how to build such a toolchain?No, especially because it will vary widely depending on your target.what i tried: ldc2 -of test -mtriple=i686-unknown-linux-gnu -relocation-model=pic test.d ld: library not found for -lrt clang: error: linker command failed with exit code 1 (use -v to see invocation) Error: /usr/bin/gcc failed with status: 1 so i guess i need a directory with all my linux libraries and the correct parameters?!It may be that all you need is the right linux libraries to link against, ie that your linker could support the usual linux executable format of ELF-x86/x64 out of the box. You can often get those libraries by downloading and unpacking the packages through which they're normally installed into your linux distro. For an example of a cross-compiler toolchain that works well, you can look at the Android NDK, which has a download for the Mac too: http://developer.android.com/ndk/downloads/index.html By cloning the samples and running their build script in verbose mode (/path/to/ndk/ndk-build V=1), you can see exactly how they setup and use their toolchain and create something similar for yourself.
Mar 30 2016
On Wednesday, 30 March 2016 at 09:57:54 UTC, Joakim wrote:On Tuesday, 29 March 2016 at 10:59:41 UTC, yawniek wrote:Btw, this would be very easy to do with the just announced "Windows Subsystem for Linux" on the next release of Windows 10: :D http://blog.dustinkirkland.com/2016/03/ubuntu-on-windows.html Perhaps you could ask Apple for something similar... ;)[...]Yes and no, ldc is a very good cross-compiler and will work for that purpose most of the time: unfortunately it cannot link those binaries yet. ;) [...]
Mar 30 2016