How to build a set of toolchains for cross-compiling for LDC?

Majestio via digitalmars-d-ldc digitalmars-d-ldc at puremagic.com
Tue Jul 14 05:26:51 PDT 2015


Hi,Kai!

On Sunday, 28 June 2015 at 18:14:13 UTC, Kai Nacke wrote:
> I described cross-compiling for AArch64 here: 
> http://forum.dlang.org/post/fhwvxatxezkafnalwhqr@forum.dlang.org

I did as you wrote. But the problem with linking.

I tried to build HelloWorld (with link error):
======================================================================
#!/bin/sh

export MXE="/home/majestio/Dev/cross/mxe/usr"
export TARGET="i686-w64-mingw32.static"
export PATH="$MXE/$TARGET/bin:$MXE/bin:$PATH"

$MXE/$TARGET/bin/ldc2 -v \
-mtriple=i686-w32-mingw32.static \
-gcc=i686-w64-mingw32.static-gcc \
-L=-L$MXE/$TARGET/lib \
hello_d.d
======================================================================

Trying to run the linker separately (with link error):
======================================================================
#!/bin/sh

export MXE="/home/majestio/Dev/cross/mxe/usr"
export TARGET="i686-w64-mingw32.static"
export PATH="$MXE/$TARGET/bin:$MXE/bin:$PATH"

$MXE/bin/$TARGET-ld -v \
hello_d.obj \
-o hello.exe \
-L$MXE/$TARGET/lib \
-lphobos2-ldc \
-lcurl \
-ldruntime-ldc \
-lws2_32 \
-lshell32
======================================================================

Output linker:
======================================================================
GNU ld (GNU Binutils) 2.25
hello_d.obj:(.text[__D3std5stdio16__T7writelnTAyaZ7writelnFAyaZv]+0x1a): undefined reference to `_D3std5stdio6stdoutS3std5stdio4File'
hello_d.obj:(.text[__D3std5stdio16__T7writelnTAyaZ7writelnFAyaZv]+0x3a): undefined reference to `__mingw_fprintf'
hello_d.obj:(.text[__D3std5stdio16__T7writelnTAyaZ7writelnFAyaZv]+0x6c): undefined reference to `_D3std9exception14__T7enforceTbZ7enforceFNaNfbLAxaAyakZb'
hello_d.obj:(.text[__D7hello_d16__moduleinfoCtorZ]+0x8): 
undefined reference to `_Dmodule_ref'
hello_d.obj:(.text[__D7hello_d16__moduleinfoCtorZ]+0x13): 
undefined reference to `_Dmodule_ref'
hello_d.obj:(.text[_main]+0x7): undefined reference to `__main'
hello_d.obj:(.text[_main]+0x2f): undefined reference to 
`_d_run_main'
hello_d.obj:(.rdata[__D12TypeInfo_xAk6__initZ]+0x0): undefined 
reference to `_D14TypeInfo_Const6__vtblZ'
hello_d.obj:(.rdata[__D12TypeInfo_Axk6__initZ]+0x0): undefined 
reference to `_D14TypeInfo_Array6__vtblZ'
hello_d.obj:(.rdata[__D11TypeInfo_xk6__initZ]+0x0): undefined 
reference to `_D14TypeInfo_Const6__vtblZ'
hello_d.obj:(.rdata[__D11TypeInfo_xk6__initZ]+0x8): undefined 
reference to `_D10TypeInfo_k6__initZ'
hello_d.obj:(.rdata[__D11TypeInfo_ya6__initZ]+0x0): undefined 
reference to `_D18TypeInfo_Invariant6__vtblZ'
hello_d.obj:(.rdata[__D11TypeInfo_ya6__initZ]+0x8): undefined 
reference to `_D10TypeInfo_a6__initZ'
hello_d.obj:(.rdata[__D12TypeInfo_xAa6__initZ]+0x0): undefined 
reference to `_D14TypeInfo_Const6__vtblZ'
hello_d.obj:(.rdata[__D12TypeInfo_xAa6__initZ]+0x8): undefined 
reference to `_D12TypeInfo_Axa6__initZ'
hello_d.obj:(.rdata[__D11TypeInfo_xb6__initZ]+0x0): undefined 
reference to `_D14TypeInfo_Const6__vtblZ'
hello_d.obj:(.rdata[__D11TypeInfo_xb6__initZ]+0x8): undefined 
reference to `_D10TypeInfo_b6__initZ'
hello_d.obj:(.rdata[__D11TypeInfo_xi6__initZ]+0x0): undefined 
reference to `_D14TypeInfo_Const6__vtblZ'
hello_d.obj:(.rdata[__D11TypeInfo_xi6__initZ]+0x8): undefined 
reference to `_D10TypeInfo_i6__initZ'
hello_d.obj:(.rdata[__D11TypeInfo_xa6__initZ]+0x0): undefined 
reference to `_D14TypeInfo_Const6__vtblZ'
hello_d.obj:(.rdata[__D11TypeInfo_xa6__initZ]+0x8): undefined 
reference to `_D10TypeInfo_a6__initZ'
hello_d.obj:(.rdata[__D11TypeInfo_xh6__initZ]+0x0): undefined 
reference to `_D14TypeInfo_Const6__vtblZ'
hello_d.obj:(.rdata[__D11TypeInfo_xh6__initZ]+0x8): undefined 
reference to `_D10TypeInfo_h6__initZ'
hello_d.obj:(.rdata[__D13TypeInfo_xAya6__initZ]+0x0): undefined 
reference to `_D14TypeInfo_Const6__vtblZ'
hello_d.obj:(.rdata[__D13TypeInfo_xAya6__initZ]+0x8): undefined 
reference to `_D12TypeInfo_Aya6__initZ'
hello_d.obj:(.data[__D7hello_d12__ModuleInfoZ]+0xc): undefined 
reference to `_D3std5stdio12__ModuleInfoZ'
======================================================================

Inside .obj (i686-w64-mingw32.static-nm hello_d.obj):
======================================================================
00000000 b .bss
00000000 d .ctors
00000000 d .data
00000000 d .data
00000000 d .data
00000000 i .drectve
00000000 d .eh_frame
00000000 r .rdata
00000000 r .rdata
00000000 r .rdata
00000000 r .rdata
00000000 r .rdata
00000000 r .rdata
00000000 r .rdata
00000000 r .rdata
00000000 r .rdata
00000000 r .rdata
00000000 r .rdata
00000000 t .text
00000000 t .text
00000000 t .text
00000000 t .text
00000000 t .text
00000000 t .text
00000001 a @feat.00
          U __D10TypeInfo_a6__initZ
          U __D10TypeInfo_b6__initZ
          U __D10TypeInfo_h6__initZ
          U __D10TypeInfo_i6__initZ
          U __D10TypeInfo_k6__initZ
00000000 R __D11TypeInfo_xa6__initZ
00000000 R __D11TypeInfo_xb6__initZ
00000000 R __D11TypeInfo_xh6__initZ
00000000 R __D11TypeInfo_xi6__initZ
00000000 R __D11TypeInfo_xk6__initZ
00000000 R __D11TypeInfo_ya6__initZ
          U __D12TypeInfo_Axa6__initZ
00000000 R __D12TypeInfo_Axk6__initZ
          U __D12TypeInfo_Aya6__initZ
00000000 R __D12TypeInfo_xAa6__initZ
00000000 R __D12TypeInfo_xAk6__initZ
00000000 R __D13TypeInfo_xAya6__initZ
          U __D14TypeInfo_Array6__vtblZ
          U __D14TypeInfo_Const6__vtblZ
          U __D18TypeInfo_Invariant6__vtblZ
          U __D3std5stdio12__ModuleInfoZ
00000000 T 
__D3std5stdio16__T7writelnTAyaZ7writelnFAyaZ12__dgliteral3MFNaNbNiNfZAxa
00000000 T __D3std5stdio16__T7writelnTAyaZ7writelnFAyaZv
          U __D3std5stdio6stdoutS3std5stdio4File
          U 
__D3std9exception14__T7enforceTbZ7enforceFNaNfbLAxaAyakZb
00000000 d __D7hello_d11__moduleRefZ
00000000 D __D7hello_d12__ModuleInfoZ
00000000 t __D7hello_d16__moduleinfoCtorZ
00000000 T __Dmain
          U __Dmodule_ref
          U ___main
          U ___mingw_fprintf
          U __d_run_main
00000000 T _main




What can be done?








More information about the digitalmars-d-ldc mailing list