Cross-compile macOS to Ubuntu

Paolo Invernizzi paolo.invernizzi at gmail.com
Thu Dec 20 17:37:23 UTC 2018


Hi all,

I'm pretty new to cross compiling, and I'm trying to 
cross-compile from a macOS to a Ubuntu machine.

I'm using, ldc-1.13.0 on macOS 12, files and libraries copied 
from a vanilla docker Ubuntu 18.04 with ldc-1.13.0.

With the relevant files in the directory `ubuntu`, and doing:
---
ln ubuntu/lib/x86_64-linux-gnu/librt-2.27.so 
ubuntu/lib/x86_64-linux-gnu/librt.so
ln ubuntu/lib/x86_64-linux-gnu/libdl-2.27.so 
ubuntu/lib/x86_64-linux-gnu/libdl.so
ln ubuntu/lib/x86_64-linux-gnu/libpthread-2.27.so 
ubuntu/lib/x86_64-linux-gnu/libpthread.so
ln ubuntu/lib/x86_64-linux-gnu/libm-2.27.so 
ubuntu/lib/x86_64-linux-gnu/libm.so

ldc2 -mtriple=x86_64-unknown-linux-gnu -link-internally 
-L-L./ubuntu/ldc-1.13.0/lib -L-L./ubuntu/lib/x86_64-linux-gnu 
-L-error-limit=0 hello.d
---

I'm almost there, I'm missing the C runtime:
---
ldc2 -mtriple=x86_64-unknown-linux-gnu -link-internally 
-L-L./ubuntu/ldc-1.13.0/lib -L-L./ubuntu/lib/x86_64-linux-gnu 
-L-error-limit=0 hello.d
lld: error: undefined symbol: fwrite
>>> referenced by hello.d
>>>               
>>> hello.o:(_D3std5stdio__T13trustedFwriteTaZQsFNbNiNePOS4core4stdcQBx8_IO_FILExAaZm)
<snip>
---

Internally, lld is invoked as:
---
lld hello.o -o hello -L./ubuntu/ldc-1.13.0/lib 
-L./ubuntu/lib/x86_64-linux-gnu -error-limit=0 
-L/Users/pinver/dlang/ldc-1.13.0/bin/../lib -lphobos2-ldc 
-ldruntime-ldc --gc-sections -lrt -ldl -lpthread -lm
---

I've tried linking against the vanilla `libc.so` but without 
success... so:

- someone can point me to correct missing `.so` and `.o` to link, 
and their location?

Thank you,
Paolo




More information about the Digitalmars-d mailing list