Thread overview
Trying to cross compile from windows to android
Jan 20, 2022
Jerry
Jan 20, 2022
H. S. Teoh
Jan 21, 2022
evilrat
Jan 21, 2022
Jerry
Jan 21, 2022
Jerry
Jan 21, 2022
Jerry
January 20, 2022

Hello, followed the guide at https://wiki.dlang.org/Build_D_for_Android
but got stuck on figuring out what linker to use.

"../ldc_android/ldc/bin/ldc2.exe" -mtriple=armv7a--linux-andro
ideabi main.d
clang: error: invalid linker name in argument '-fuse-ld=bfd'
Error: ldc_android/android_ndk/toolchains/llvm/prebuilt/windows-x86_64/bin
/aarch64-linux-android21-clang.cmd failed with status: 1

Do I need to install a GNU linker with cross compile compatabilities or is my system not configured properly?

January 20, 2022
On Thu, Jan 20, 2022 at 07:10:40PM +0000, Jerry via Digitalmars-d-learn wrote:
> Hello, followed the guide at https://wiki.dlang.org/Build_D_for_Android but got stuck on figuring out what linker to use.
> 
> "../ldc_android/ldc/bin/ldc2.exe" -mtriple=armv7a--linux-andro
> ideabi main.d
> clang: error: invalid linker name in argument '-fuse-ld=bfd'
> Error: ldc_android/android_ndk/toolchains/llvm/prebuilt/windows-x86_64/bin
> /aarch64-linux-android21-clang.cmd failed with status: 1
> 
> Do I need to install a GNU linker with cross compile compatabilities or is my system not configured properly?

You're trying to use bfd as your linker, and I think that only exists on the Linux version of the NDK. Maybe try looking somewhere under ldc_android/android_ndk/toolchains/x86_64-*/prebuilt/windows-x86_64/bin to see what linkers are shipped with your NDK, and specify that instead?

On Linux, I see a bunch of binaries named x86_64-linux-android-*, including *-ld, *-ld.bfd, *-ld.gold, which are the 3 linkers that can be used via -fuse-ld=bfd, -fuse-ld=gold, etc..  I'm not sure how it works on Windows, but there should be corresponding binaries that might give a hint as to what's the correct -fuse-ld=... option you need to use.


T

-- 
Famous last words: I *think* this will work...
January 21, 2022
On Thursday, 20 January 2022 at 19:31:06 UTC, H. S. Teoh wrote:
> I'm not sure how it works on Windows, but there should be corresponding binaries that might give a hint as to what's the correct -fuse-ld=... option you need to use.
>

Here I documented some of the quirks I've hit during android prototyping.
Works like this, no idea if it is still up to date though.

https://github.com/Superbelko/android-sdl-d/blob/master/guide/README.md
January 21, 2022
On Thursday, 20 January 2022 at 19:31:06 UTC, H. S. Teoh wrote:
> On Thu, Jan 20, 2022 at 07:10:40PM +0000, Jerry via Digitalmars-d-learn wrote:
>
> You're trying to use bfd as your linker, and I think that only exists on the Linux version of the NDK. Maybe try looking somewhere under ldc_android/android_ndk/toolchains/x86_64-*/prebuilt/windows-x86_64/bin to see what linkers are shipped with your NDK, and specify that instead?
>
> On Linux, I see a bunch of binaries named x86_64-linux-android-*, including *-ld, *-ld.bfd, *-ld.gold, which are the 3 linkers that can be used via -fuse-ld=bfd, -fuse-ld=gold, etc..  I'm not sure how it works on Windows, but there should be corresponding binaries that might give a hint as to what's the correct -fuse-ld=... option you need to use.
>
>
> T

Thank you mate, got it working now. With the ld linker.
January 21, 2022
On Thursday, 20 January 2022 at 19:31:06 UTC, H. S. Teoh wrote:
> T

Found ld linker as you described.
Slapped on the --linker=ld flag and now everything is working. Thanks! :D
January 21, 2022
On Friday, 21 January 2022 at 09:52:10 UTC, Jerry wrote:
> On Thursday, 20 January 2022 at 19:31:06 UTC, H. S. Teoh wrote:
>> T
>
> Found ld linker as you described.
> Slapped on the --linker=ld flag and now everything is working. Thanks! :D

Or atleast that's what I thought, it links, but won't run, apparently bfd linker is required. So I installed that one.