Jump to page: 1 2 3
Thread overview
D on android and d_android
Apr 01, 2020
burt
Apr 01, 2020
Adam D. Ruppe
Apr 01, 2020
burt
Apr 01, 2020
burt
Apr 01, 2020
Adam D. Ruppe
Apr 01, 2020
burt
Apr 01, 2020
Adam D. Ruppe
Apr 01, 2020
burt
Apr 01, 2020
Adam D. Ruppe
Apr 01, 2020
burt
Apr 01, 2020
Adam D. Ruppe
Apr 01, 2020
burt
Apr 02, 2020
Adam D. Ruppe
Apr 02, 2020
burt
Apr 02, 2020
Adam D. Ruppe
Apr 02, 2020
burt
Apr 05, 2020
burt
Apr 06, 2020
Jan Hönig
Apr 07, 2020
Adam D. Ruppe
Apr 07, 2020
H. S. Teoh
Apr 07, 2020
Jan Hönig
Apr 07, 2020
Adam D. Ruppe
Apr 07, 2020
H. S. Teoh
Apr 07, 2020
Jan Hönig
Apr 07, 2020
burt
Apr 07, 2020
Adam D. Ruppe
Apr 07, 2020
burt
April 01, 2020
Hi,

I'm trying to compile a simple app with D code to Android and trying to use the d_android library for this. While trying to compile a basic sample, I found a README [0] that mentions an "android-dub-build.d" script, which should be a wrapper around `dub build`, but I cannot find this file after downloading the dub package and also not on github; is this a mistake, or should I find it somewhere else?

Thank you in advance.

[0] https://github.com/adamdruppe/d_android/tree/master/android-dub-test
April 01, 2020
On Wednesday, 1 April 2020 at 08:50:01 UTC, burt wrote:
> I found a README [0] that mentions an "android-dub-build.d" script, which should be a wrapper around `dub build`

Ah, I forgot to update that file. There is no android-dub-build anymore, instead the android-setup changes the main configuration file so plain `dub build` just works.

So the correct steps now:

1) get ldc 1.19 specifically and the android NDK
2) do `android-setup /path/to/your/android/ndk`
3) do normal `dub build`
April 01, 2020
On Wednesday, 1 April 2020 at 11:57:58 UTC, Adam D. Ruppe wrote:
> On Wednesday, 1 April 2020 at 08:50:01 UTC, burt wrote:
>> I found a README [0] that mentions an "android-dub-build.d" script, which should be a wrapper around `dub build`
>
> Ah, I forgot to update that file. There is no android-dub-build anymore, instead the android-setup changes the main configuration file so plain `dub build` just works.
>
> So the correct steps now:
>
> 1) get ldc 1.19 specifically and the android NDK
> 2) do `android-setup /path/to/your/android/ndk`
> 3) do normal `dub build`

Thank you for your response, I managed to get a simple no-druntime-no-phobos app running with a function written in D.

Now I am trying to create a wrapper around a library that uses the runtime and phobos extensively, and even though the `libphobos2-ldc.a` and `libdruntime-ldc.a` files (created by `android-setup.d`) have been linked into the .a file that resulted from using
> dub build --compiler=ldc2 --arch=armv7a-none-linux-android
on my library, I still get linker errors telling me that symbols from phobos and druntime are undefined. (At least, I think I linked them in properly, because the size is approximately equal to the sizes of `libphobos2-ldc.a` and `libdruntime-ldc.a` added up.) Do you have any idea what could be wrong with my setup?

I am on windows and am using Android Studio v3.6.1, NDK 21.0.6113669 and the newest version of LDC2.

Thanks in advance.

April 01, 2020
>> So the correct steps now:
>>
>> 1) get ldc 1.19 specifically and the android NDK
>> 2) do `android-setup /path/to/your/android/ndk`
>> 3) do normal `dub build`

Sorry, I must have misread this. My LDC version was 1.20.1, not 1.19.

Thanks

April 01, 2020
On Wednesday, 1 April 2020 at 13:36:29 UTC, burt wrote:
> Sorry, I must have misread this. My LDC version was 1.20.1, not 1.19.

did that fix the linker error?

The runtimes it downloads are specifically built against 1.19. But libs for the other versions are available too, you just need to download the Android versions of ldc and copy them out to the appropriate place. My downloader just isn't smart enough to do it... yet. It is on my todo list though, just so are a million other things.
April 01, 2020
On Wednesday, 1 April 2020 at 14:00:39 UTC, Adam D. Ruppe wrote:
> On Wednesday, 1 April 2020 at 13:36:29 UTC, burt wrote:
>> Sorry, I must have misread this. My LDC version was 1.20.1, not 1.19.
>
> did that fix the linker error?
>
> The runtimes it downloads are specifically built against 1.19. But libs for the other versions are available too, you just need to download the Android versions of ldc and copy them out to the appropriate place. My downloader just isn't smart enough to do it... yet. It is on my todo list though, just so are a million other things.

Unfortunately downgrading my LDC to 1.19 did not fix the linker errors. I used `android-setup.d` for this version again and recompiled my project using LDC 1.19, however the errors still occur.

I also wonder if there's a difference between the libphobos2-ldc and libphobos2-ldc-debug.a libraries? Do those mangle differently and could that cause the linker errors?

April 01, 2020
On Wednesday, 1 April 2020 at 14:13:32 UTC, burt wrote:
> I also wonder if there's a difference between the libphobos2-ldc and libphobos2-ldc-debug.a libraries? Do those mangle differently and could that cause the linker errors?

maybe. what are the errors?
April 01, 2020
On Wednesday, 1 April 2020 at 14:16:28 UTC, Adam D. Ruppe wrote:
> On Wednesday, 1 April 2020 at 14:13:32 UTC, burt wrote:
>> I also wonder if there's a difference between the libphobos2-ldc and libphobos2-ldc-debug.a libraries? Do those mangle differently and could that cause the linker errors?
>
> maybe. what are the errors?

Some examples of errors are:

> ...\ldc2-1.19.0-windows-x64\bin\..\import\std/utf.d:0: error: undefined reference to '_D3std3utf12UTFException7__ClassZ'

> ...\dub\packages\arsd-official-7.0.0\arsd-official/jni.d:0: error: undefined reference to '_D9Exception6__initZ'

> ...\ldc2-1.19.0-windows-x64\bin\..\import/object.d:3109: error: undefined reference to '_d_arraysetcapacity'

> .../parser.d:697: error: undefined reference to '_d_newarrayU'

Strange is that even symbols that are not mangled (such as _d_arraysetcapacity) cannot be found, even though these should always mangle the same.

April 01, 2020
On Wednesday, 1 April 2020 at 14:20:25 UTC, burt wrote:
> Some examples of errors are:

Those mean it isn't linking in the libs at all... ugh.

do

ldc2 -v

and it will tell you where the config file is.

open that up and see if it has teh correct paths under a section that looks kinda like

"armv7a-.*-linux-android":
{
    switches = [
        "-defaultlib=phobos2-ldc,druntime-ldc",
        "-link-defaultlib-shared=false",
        "-gcc=$NDK/toolchains/llvm/prebuilt/$OS/bin/armv7a-linux-androideabi21-clang$EXT",
        "-linker=bfd",
        "-mcpu=cortex-a8",
    ];
    lib-dirs = [
        "$D_ANDROID/runtime_droid_armeabi-v7a",
    ];




That lib-dirs one in particular is what I'm interested in.
April 01, 2020
On Wednesday, 1 April 2020 at 14:31:45 UTC, Adam D. Ruppe wrote:
> On Wednesday, 1 April 2020 at 14:20:25 UTC, burt wrote:
>> Some examples of errors are:
>
> Those mean it isn't linking in the libs at all... ugh.
>
> do
>
> ldc2 -v
>
> and it will tell you where the config file is.
>
> open that up and see if it has teh correct paths under a section that looks kinda like
>
> "armv7a-.*-linux-android":
> {
>     switches = [
>         "-defaultlib=phobos2-ldc,druntime-ldc",
>         "-link-defaultlib-shared=false",
>         "-gcc=$NDK/toolchains/llvm/prebuilt/$OS/bin/armv7a-linux-androideabi21-clang$EXT",
>         "-linker=bfd",
>         "-mcpu=cortex-a8",
>     ];
>     lib-dirs = [
>         "$D_ANDROID/runtime_droid_armeabi-v7a",
>     ];
>
> That lib-dirs one in particular is what I'm interested in.

It gives me lib-dirs = [ "C:/Users/<myname>/Programs/runtime_droid_armeabi-v7a", ];

At that location this folder is located and the contents are libdruntime-ldc.a, libdruntime-ldc-debug.a, libphobos2-ldc.a and libphobos2-ldc-debug.a. Sizes are 2511 kB, 4792 kB, 10.010 kB and 17.378 kB respectively.

During another attempt I copied those folder to my dub project and included the path to those folders in my dub.json as "lflags": ["--library-path=./runtime_droid_armeabi-v7a"]. This gave me exactly the same errors.

Other ldc2.conf contents for that section was as follows:
switches = [
        "-defaultlib=phobos2-ldc,druntime-ldc",
        "-link-defaultlib-shared=false",
        "-gcc=C:/Users/<user>/AppData/Local/Android/Sdk/ndk/21.0.6113669/toolchains/llvm/prebuilt/windows-x86_64/bin/armv7a-linux-androideabi21-clang.cmd",
        "-linker=bfd",
        "-mcpu=cortex-a8",
    ];



« First   ‹ Prev
1 2 3