Cross-compile macOS to Ubuntu
kinke
noone at nowhere.com
Thu Dec 20 21:47:40 UTC 2018
On Thursday, 20 December 2018 at 17:37:23 UTC, Paolo Invernizzi
wrote:
> 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?
That mess wrt. distro-specific default libs/object files/other
switches being injected by gcc into the linker command line is
the reason we recommend using a cross-gcc toolchain for Linux/BSD
targets. Anyway, you can invoke `gcc dummy.c -v` in Ubuntu to
check the default linker args added by gcc, and work your way
from there. E.g., see the first paragraph in
https://github.com/ldc-developers/ldc/pull/2203#issuecomment-339167131. In my case on Ubuntu 18.04, the ugly linker cmdline is:
/usr/lib/gcc/x86_64-linux-gnu/7/collect2 -plugin
/usr/lib/gcc/x86_64-linux-gnu/7/liblto_plugin.so
-plugin-opt=/usr/lib/gcc/x86_64-linux-gnu/7/lto-wrapper
-plugin-opt=-fresolution=/tmp/ccqp6nEf.res
-plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lgcc_s
-plugin-opt=-pass-through=-lc -plugin-opt=-pass-through=-lgcc
-plugin-opt=-pass-through=-lgcc_s --sysroot=/ --build-id
--eh-frame-hdr -m elf_x86_64 --hash-style=gnu --as-needed
-dynamic-linker /lib64/ld-linux-x86-64.so.2 -pie -z now -z relro
/usr/lib/gcc/x86_64-linux-gnu/7/../../../x86_64-linux-gnu/Scrt1.o
/usr/lib/gcc/x86_64-linux-gnu/7/../../../x86_64-linux-gnu/crti.o
/usr/lib/gcc/x86_64-linux-gnu/7/crtbeginS.o
-L/usr/lib/gcc/x86_64-linux-gnu/7
-L/usr/lib/gcc/x86_64-linux-gnu/7/../../../x86_64-linux-gnu
-L/usr/lib/gcc/x86_64-linux-gnu/7/../../../../lib
-L/lib/x86_64-linux-gnu -L/lib/../lib -L/usr/lib/x86_64-linux-gnu
-L/usr/lib/../lib -L/usr/lib/gcc/x86_64-linux-gnu/7/../../..
<DUMMY.o> -lgcc --push-state --as-needed -lgcc_s --pop-state -lc
-lgcc --push-state --as-needed -lgcc_s --pop-state
/usr/lib/gcc/x86_64-linux-gnu/7/crtendS.o
/usr/lib/gcc/x86_64-linux-gnu/7/../../../x86_64-linux-gnu/crtn.o
More information about the Digitalmars-d
mailing list