Inquiring about cross compilation

Adrian Matoga via D.gnu d.gnu at puremagic.com
Mon Feb 29 00:35:52 PST 2016


On Saturday, 27 February 2016 at 16:27:31 UTC, Ken Burgett wrote:
> I am looking at doing a D project and have installed the DMD 
> compiler on my 64-bit Ubuntu dev system.  My target 
> architecture to ARM, as used in the Raspberry PI and other 
> systems.  I need to know how I can develop code on Linux x86 
> and run it on the RPI.  Any pointer to an article about this 
> topic is appreciated.

Download x86_64-linux-gnu toolchain targeting arm-linux-gnueabihf 
from [1] (its the second row). For Raspberry Pi it works out of 
the box, try:

$ /opt/arm-linux-gnueabihf/bin/arm-linux-gnueabihf-gdc hello.d -o 
hello

$ file hello
hello: ELF 32-bit LSB  executable, ARM, EABI5 version 1 (SYSV), 
dynamically linked (uses shared libs), for GNU/Linux 2.6.32, not 
stripped

To build with dub, you need to pass the --compiler flag, e.g.

$ dub build 
--compiler=/opt/arm-linux-gnueabihf/bin/arm-linux-gnueabihf-gdc

This can even build vibe.d apps for RPi, provided that you have 
all target .so files (AFAIK these are libevent, libevent_pthread, 
libssl and libcrypto).

qemu-arm-static can execute statically linked ARM linux apps 
right on your PC.

You can also build for bare metal ARM (even Cortex-M) with the 
same toolchain if you pass correct flags. See [2].

[1] http://gdcproject.org/downloads
[2] 
http://wiki.dlang.org/Minimal_semihosted_ARM_Cortex-M_"Hello_World"



More information about the D.gnu mailing list