Cannot load library: reloc_library[1285]: cannot locate 'rand'

陌路散爱 提交于 2019-11-26 08:36:34
mstorsjo

This happens if you've built your native components with the android-21 target, but are trying to run it on a device with an older Android version. Unless you take very special care, you can't run binaries built with the android-21 target on older devices. For basic C functions, it shouldn't matter which target version between android-3 and android-20 you use, it should work on all of them, but if you use android-21 it only works on that version and newer.

See https://stackoverflow.com/a/27093163/3115956 for more details on this issue.

mstorsjo answers my question. But i want write one comment: I had correct properties files, but during pjsip building I found following logs:

sip@ubuntu:~/pjsip/trunk$ ./configure-android
configure-android: APP_PLATFORM not specified, using android-21
configure-android: TARGET_ABI not specified, using armeabi

So if you want compile the project on some specific platform version, you have to set APP_PLATFORM parameter for configure-android script.

TARGET_ABI=armeabi-v7a APP_PLATFORM=android-8 ./configure-android --use-ndk-cflags

I have encountered this when using HUAWEI phone with opus and pngquant jni library for android. Finally the solution is that I add rand,srand and atof function implementions in my source file. Then the problem gone.

Solution from https://github.com/cocos2d/cocos2d-x/issues/15234 Try it!

static u_long myNextRandom = 1;

double atof(const char *nptr)

{
    return (strtod(nptr, NULL));
}

int rand(void)
{
    return (int)((myNextRandom = (1103515245 * myNextRandom) + 12345) % ((u_long)RAND_MAX + 1));
}

void srand(u_int seed)
{
    myNextRandom = seed;
}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!