Thread overview
how do i fix undefined reference with betterC ?
Oct 12, 2018
test
Oct 12, 2018
Joakim
Oct 12, 2018
test
Oct 15, 2018
Joakim
Oct 15, 2018
Kagamin
Oct 15, 2018
Kagamin
Oct 16, 2018
test
Oct 12, 2018
Kagamin
October 12, 2018
I am use betterC with pthread_attr_t and 1.12.0 (DMD v2.082.0, LLVM 7.0.0) for Android 64 in termux,  get this error:

undefined reference to `_D4core3sys5posixQk5types14pthread_attr_t6__initZ'

The same code in linux and macOS has no error ?
October 12, 2018
On Friday, 12 October 2018 at 02:27:35 UTC, test wrote:
>
> I am use betterC with pthread_attr_t and 1.12.0 (DMD v2.082.0, LLVM 7.0.0) for Android 64 in termux,  get this error:
>
> undefined reference to `_D4core3sys5posixQk5types14pthread_attr_t6__initZ'

beta1 or beta2? Cross-compiling or natively compiling?

> The same code in linux and macOS has no error ?

Are you using betterC on those other platforms too? I believe that's a druntime symbol that it's generating, which shouldn't be there for betterC. I'm able to reproduce this in Termux natively but not on linux/x64, could be a bug in betterC or an even longer-standing issue where the D frontend randomly puts out those symbols.

File an issue on github and we'll look into it:

https://github.com/ldc-developers/ldc/issues
October 12, 2018
On Friday, 12 October 2018 at 02:27:35 UTC, test wrote:
>
> I am use betterC with pthread_attr_t and 1.12.0 (DMD v2.082.0, LLVM 7.0.0) for Android 64 in termux,  get this error:
>
> undefined reference to `_D4core3sys5posixQk5types14pthread_attr_t6__initZ'
>
> The same code in linux and macOS has no error ?

You can just leave it uninitialized
pthread_attr_t attr=void;
You will need to call pthread_attr_init anyway.
October 12, 2018
On Friday, 12 October 2018 at 03:02:55 UTC, Joakim wrote:
> https://github.com/ldc-developers/ldc/issues

I use ldmd2-beta on my Galaxy Phone, use BetterC on destroy and android.

I am not sure how to reduct the code exmaple, if I can get a example will try open issue.

@Kagamin

Thanks for tips.
October 15, 2018
On Friday, 12 October 2018 at 12:24:04 UTC, test wrote:
> On Friday, 12 October 2018 at 03:02:55 UTC, Joakim wrote:
>> https://github.com/ldc-developers/ldc/issues
>
> I use ldmd2-beta on my Galaxy Phone, use BetterC on destroy and android.
>
> I am not sure how to reduct the code exmaple, if I can get a example will try open issue.

It's okay, I filed an issue with my reproducible sample code:

https://github.com/ldc-developers/ldc/issues/2876

I was only able to reproduce with 64-bit ARM, not 32-bit. Same for you?

> @Kagamin
>
> Thanks for tips.

I confirmed that his workaround fixed this problem.
October 15, 2018
pthread_attr_t is 5*size_t size, which might confuse initializer, but also has a gap on 64-bit.
October 15, 2018
Oops, no, it's likely char[16], in C char sometimes means byte, not text.
October 16, 2018
On Monday, 15 October 2018 at 08:31:25 UTC, Joakim wrote:
> I was only able to reproduce with 64-bit ARM, not 32-bit. Same for you?

I only has a 64-bit android, and don't know how to made 32-bit to work on 64-bit termux.

>> Thanks for tips.
>
> I confirmed that his workaround fixed this problem.


Yes, thanks again.

I  have never develop on Android, the plan is to write  a so file from Termux copy it into my desk, build with Android studio and SDK 26.


I plan use betterC to avoid GC.

Do I have to install SDK 26 or some NDK package on Termux to build so file, and the so file can be used on my Desktop android studio project ?

How to modify this file to use my so files?


apply plugin: 'com.android.application'

android {
    compileSdkVersion 28
    defaultConfig {
        applicationId "com.hahaha.demo"
        minSdkVersion 23
        targetSdkVersion 28
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        ndk {
            moduleName = "TestProject"
            abiFilters "armeabi-v7a"
        }
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    productFlavors {
        create("arm") {
            ndk.with {
                abiFilters += "armeabi-v7a"
                ndk.ldFlags += "-L${file("lib/armeabi-v7a/")}".toString()
            }
        }
    }
}

dependencies {
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    implementation 'com.android.support:appcompat-v7:28.0.0'
}