Hi all!
I apologize in advance for my English, I use Google Translator :-\
I became interested in the D programming language recently. I want build a comfortable environment for cross-compilation. In my Linux Funtoo already has a similar environment for C/C++ based http://mxe.cc:
i686-w64-mingw32.shared
i686-w64-mingw32.static
x86_64-w64-mingw32.shared
x86_64-w64-mingw32.static
... and more libs, including Qt 5.4.2 for each toolchain.
So far I have built native LDC, and native "Hello world" is compiled and linked successfully.
Actually, the question is how to build step by step for the environment LDC for cross-compile, similar MXE?
Just in case, my directory structure:
/home/majestio/dev/cross/mxe - C/C++ cross-compile env
/home/majestio/dev/cross/llvm - LLVM,Clang,LDC
WBR

On Sunday, 28 June 2015 at 14:03:15 UTC, Majestio wrote:
> Hi all!
>> I apologize in advance for my English, I use Google Translator :-\
>> I became interested in the D programming language recently. I want build a comfortable environment for cross-compilation. In my Linux Funtoo already has a similar environment for C/C++ based http://mxe.cc:
>> i686-w64-mingw32.shared
> i686-w64-mingw32.static
> x86_64-w64-mingw32.shared
> x86_64-w64-mingw32.static
>> ... and more libs, including Qt 5.4.2 for each toolchain.
>> So far I have built native LDC, and native "Hello world" is compiled and linked successfully.
>> Actually, the question is how to build step by step for the environment LDC for cross-compile, similar MXE?
>> Just in case, my directory structure:
>> /home/majestio/dev/cross/mxe - C/C++ cross-compile env
> /home/majestio/dev/cross/llvm - LLVM,Clang,LDC
>> WBR
Hi Majestio!
You need to compile LLVM for the targets you want. With USE flag multitarget, LLVM is build for all available targets. Then rebuild LDC with this LLVM.
I described cross-compiling for AArch64 here: http://forum.dlang.org/post/fhwvxatxezkafnalwhqr@forum.dlang.org
Regards,
Kai

On Tuesday, 14 July 2015 at 12:26:53 UTC, Majestio wrote:
> 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.
>> What can be done?
Hi Majestio!
First, your link command is definitively incomplete.
At least libc and libpthread are missing. You are using ld so I miss the crt*.o files, too. I would recommend to use the cross-gcc for linking.
Symptons for this are:
> hello_d.obj:(.text[_main]+0x7): undefined reference to `__main'
> hello_d.obj:(.text[__D3std5stdio16__T7writelnTAyaZ7writelnFAyaZv]+0x3a): undefined reference to `__mingw_fprintf'
These are symbols from the MingW C library.
BTW: Can you cross-compile a C hello world without problems?
Did you compile druntime and phobos for the mingw target? If yes where did you place the libraries?
The other missing symbols are from druntime and phobos. This indicates that these libraries are not found. Did you also cross-compile the curl library?
You can use the -v command line option with ldc2 to see the call to gcc. This is useful for debugging.
Regards,
Kai

On Friday, 17 July 2015 at 07:54:03 UTC, Majestio wrote:
> Just in case the attached file: https//yadi.sk/d/bdD44pMYhvEG8
Hi Majestio!
The files were helpful. You need to add -mtriple=i686-w64-mingw32.static to D_FLAGS variable in runtime/CMakeLists.txt and recompile the libraries.
What happened is that the object files in the library are ELF-64 (compiled for x86-64 Linux) but hello.o is 80386 COFF. Therefore the unresolved references.
What I miss is the error message from the linker, complaining about the architecture mismatch...
Regards,
Kai