Closed sr-tream closed 5 years ago
I have an almost similiar scenario, compiling from Windows to raspberry pi. The trick is to pass as dub argument --compiler a shell script which name has to include the text ldc2. In my case ldc2pi.bat. You have to create a file ldc2win.sh and translate the batch code to bash code. See here the full tutorial http://d-land.sepany.de/tutorials/einplatinenrechner/einstieg-in-die-raspberry-pi-entwicklung-mit-ldc/ (You may use Google translator)
@andre2007 I have such a script (https://git.prime-hack.net/SR_team/wldc), and dub can build standalone programs. The problem arises when it is necessary to build a program with dependencies
I am not 100% sure you have the same script. In my scenario I have a batch script (bash script in your scenario) which is called like this dub build --compiler ldc2pi.bat
.
@andre2007
I can use dub like dub build --compiler=wldc2.d
And this scenario is work:
dub init helloworld
cd helloworld
dub build --compiler-wldc2.d
So, building is failed if helloworld has dependencies that are static libraries. Example - helloworld for dlangui. The problem is caused by this. Dub has no means to specify the platform, only auto-detection
Now I am confused. Some months ago the scenario you describes was working for me (Generating raspberrry pi applications from Windows). I also used a package "serialport" which has target type "library". I just did a test and I am not longer able to get the scenario working. I get the error " unrecognized file extension lib". Something has changed but I do not know what has changed...
Update: Whether dub creates a lib/a file depends on output of "ldc2 -version" https://github.com/dlang/dub/blob/master/source/dub/compilers/ldc.d#L221
Quick fix: your --compiler script could return on - version request a fixed text pointing the dub auto detection logic into the right direction...
Some months ago the scenario you describes was working for me
On linux used POSIX, on windows POSIX/MSVC. LDC2 (linux version) can build for windows, but it can build MSVC, not POSIX (or I noob, becaus I cannot build in POSIX mode).
POSIX objects extension: .o POSIX static lib extension: .a MSVC objects extension: .obj MSVC static lib extension: .lib
With flag --compiler
dub compile valid MSVC object files and static libs, BUT with POSIX extension. And linker can't link the, becaus used invalid extensions.
Something has changed but I do not know what has changed...
extension
Update: Whether dub creates a lib/a file depends on output of "ldc2 -version"
LDC - the LLVM D compiler (1.12.0):
based on DMD v2.082.1 and LLVM 7.0.0
built with LDC - the LLVM D compiler (1.11.0)
Default target: x86_64-pc-linux-gnu
Host CPU: bdver2
http://dlang.org - http://wiki.dlang.org/LDC
Registered Targets:
aarch64 - AArch64 (little endian)
aarch64_be - AArch64 (big endian)
amdgcn - AMD GCN GPUs
arm - ARM
arm64 - ARM64 (little endian)
armeb - ARM (big endian)
bpf - BPF (host endian)
bpfeb - BPF (big endian)
bpfel - BPF (little endian)
hexagon - Hexagon
lanai - Lanai
mips - Mips
mips64 - Mips64 [experimental]
mips64el - Mips64el [experimental]
mipsel - Mipsel
msp430 - MSP430 [experimental]
nvptx - NVIDIA PTX 32-bit
nvptx64 - NVIDIA PTX 64-bit
ppc32 - PowerPC 32
ppc64 - PowerPC 64
ppc64le - PowerPC 64 LE
r600 - AMD GPUs HD2XXX-HD6XXX
sparc - Sparc
sparcel - Sparc LE
sparcv9 - Sparc V9
systemz - SystemZ
thumb - Thumb
thumbeb - Thumb (big endian)
x86 - 32-bit X86: Pentium-Pro and above
x86-64 - 64-bit X86: EM64T and AMD64
xcore - XCore
Quick fix: your --compiler script could return on - version request a fixed text pointing the dub auto detection logic into the right direction...
Great idea! I try it later, but it don't close my issue
I haven't tried the methods in this thread, but for completeness: It's possible to build Windows binaries on Linux by installing a complete Windows D toolchain in Wine.
bin
directory to Wine's path variable.wine dub --compiler=ldc2
.Still, I'm interested in cross-compiling with a Linux-native compiler and dub. Would be great to generate everything with one toolchain.
Duplicate of https://github.com/dlang/dub/issues/1523
Resolved by #1755.
I can use ldc2 to build windows binaries. E.g.:
It nice work with Makefiles and cusotm build system, but I cannot use it wit dub. Dub generate .a files for static libs and building failed on linker.