android / ndk

The Android Native Development Kit
1.97k stars 255 forks source link

minSdkVersion 19 got error, undefined reference to 'rand' #769

Closed cyxcw1 closed 6 years ago

cyxcw1 commented 6 years ago

Description

When I use minSdkVersion 19 compile my project, and in the link step, I got this error: libtomcrypt/android/armeabi-v7a/libtommath.a(bn_mp_rand.c.o):../../tomcrymath/tommath/bn_mp_rand.c:function mp_rand: error: undefined reference to 'rand' But I change my minSdkVersion to 21, the error disappear. My APP must support API 19, Do we have some workaround to solve this problem?

Environment Details

enh commented 6 years ago

luckily for you, they deleted that code to fix https://github.com/libtom/libtommath/issues/103 so you probably just want to upgrade. (you might also want to send them a patch to add BIONIC to the list of libcs that have arc4random.)

looking at that patch, i think the problem with their old code was that they were missing the necessary #include <stdlib.h>. if you can't upgrade to the current code for some reason, you should find that adding the missing #include gets you the workaround as an inline from our headers.

cyxcw1 commented 6 years ago

@enh Thank you very much. But I got another question about minSdkVersion 19: https://github.com/android-ndk/ndk/issues/770