Thread overview
Cross Compiling With LDC Under Single OS
Dec 16
kinke
Dec 18
kinke
December 16
Hi, I'm new started the Dlang. I want to cross compile with LDC on a single operating system but when I follow the steps in the link below, I get a problem:

https://wiki.dlang.org/Cross-compiling_with_LDC

Under Linux;

ldc -mtriple = x86_64-windows-msvc -c foo.d -of = foo.exe

The exe file I created with the command, doesn't work in Windows 10. Likewise, my Linux code that I compiled under Windows doesn't work on Linux.

Can you help me?
December 16
On 12/16/20 8:30 AM, Elina Küçükay wrote:

> https://wiki.dlang.org/Cross-compiling_with_LDC

Could someone please review whether the instructions on that page are up-to-date. Thank you.

Should Elina try gdc instead? Do others have experience in cross-compiling with gdc?

Ali


December 16
On Wednesday, 16 December 2020 at 21:28:19 UTC, Ali Çehreli wrote:
> On 12/16/20 8:30 AM, Elina Küçükay wrote:
>
> > https://wiki.dlang.org/Cross-compiling_with_LDC
>
> Could someone please review whether the instructions on that page are up-to-date. Thank you.

They are up-to-date.

> Should Elina try gdc instead? Do others have experience in cross-compiling with gdc?

GDC doesn't support Windows.

On Wednesday, 16 December 2020 at 16:30:07 UTC, Elina Küçükay wrote:
> The exe file I created with the command, doesn't work in Windows 10. Likewise, my Linux code that I compiled under Windows doesn't work on Linux.

Please be more specific, I can't provide any remote help based on 'it doesn't work'.
December 18
On Wednesday, 16 December 2020 at 22:32:02 UTC, kinke wrote:
>
> Please be more specific, I can't provide any remote help based on 'it doesn't work'.

Thank you for all response. Dear @kinke, my goal is to create an executable file on the Linux operating system that can run on Windows. In the first transmission, I reviewed the document written for LLVM, but wasn't successful. The command below creates the exe file for me but this exe file doesn't work in Windows.

ldc -mtriple = x86_64-windows-msvc -c foo.d -of = foo.exe

GDC does not support Windows, so I am trying to compile with LLVM. Does LDC support platform independent compilation for D language?

I apologize for answering late, I did not have the opportunity to write an answer due to my exams.
December 18
On Friday, 18 December 2020 at 11:00:01 UTC, Elina Küçükay wrote:
> but this exe file doesn't work in Windows

I meant more specifics wrt. this - what's the error? Not a PE executable? Some missing DLL because a Visual C++ runtime 2015+ isn't installed?

> ldc -mtriple = x86_64-windows-msvc -c foo.d -of = foo.exe

The Wiki uses `ldc2 -mtriple=x86_64-windows-msvc foo.d`. `-c` means 'compile only', so you're effectively compiling a COFF object file and naming it `foo.exe`, so no, that won't work.

> Does LDC support platform independent compilation for D language?

Yes, the Wiki page isn't made up. ;)
December 18
On Friday, 18 December 2020 at 13:40:09 UTC, kinke wrote:
> I meant more specifics wrt. this - what's the error? Not a PE executable? Some missing DLL because a Visual C++ runtime 2015+ isn't installed?

I'm compiling under in Linux. When I remove -c parameter, I will get this error: https://paste.ubuntu.com/p/7dw9CxG4BJ/

ldc -mtriple=x86_64-windows-msvc foo.d

-----
I'm downloading LDC for Windows release for usage missing libraries under Linux. When I include missing library with -L-L= parameter, get an error again.

ldc -mtriple=x86_64-windows-msvc -L-L=lib/mingw foo.d -of=foo.exe

I may not have written clearly, I don't have very good English. As I mentioned, I just started the D language and my goal is to make a very simple D console program workable for Windows.
December 18
On 2020-12-18 18:00, Elina Küçükay wrote:

> I'm compiling under in Linux. When I remove -c parameter, I will get this error: https://paste.ubuntu.com/p/7dw9CxG4BJ/
> 
> ldc -mtriple=x86_64-windows-msvc foo.d
> 
> -----
> I'm downloading LDC for Windows release for usage missing libraries under Linux. When I include missing library with -L-L= parameter, get an error again.
> 
> ldc -mtriple=x86_64-windows-msvc -L-L=lib/mingw foo.d -of=foo.exe

The first error that you linked to indicate that you're missing the standard library and runtime library compiled for Windows. You can get those by downloading the Windows version of LDC, unpack it and place the files in the lib32/lib64 directory in the lib32/lib64 directory of your Linux LDC version. This is available here in the documentation [1].

The second error, is that the same error or a new error? You need to include the error in your message so we can see it to be able to help you.

[1] https://wiki.dlang.org/Cross-compiling_with_LDC#Default_libraries

-- 
/Jacob Carlborg
December 19
On Friday, 18 December 2020 at 19:07:48 UTC, Jacob Carlborg wrote:
> The first error that you linked to indicate that you're missing the standard library and runtime library compiled for Windows. You can get those by downloading the Windows version of LDC, unpack it and place the files in the lib32/lib64 directory in the lib32/lib64 directory of your Linux LDC version. This is available here in the documentation [1].
>
> The second error, is that the same error or a new error? You need to include the error in your message so we can see it to be able to help you.
>
> [1] https://wiki.dlang.org/Cross-compiling_with_LDC#Default_libraries

Thank you for your response. I solved it.