Android NDK Cannot load library: reloc_library[130

2019-08-12 06:06发布

Im developing an android app thats loading two shared libraries. One is external, its called libpcan.so . Usually its build to libpcan.so.0.6, this somehow cant be used by my android, i so changed the gcc flags compiling it from:

arm-linux-androideabi-gcc src/libpcan.c -fPIC -shared -O2 -Wall -Wl,-soname,-libpcan.so.0 -lc -I. -I../driver -DNO_RT -o -libpcan.so.0.6
ln -sf libpcan.so.0.6 libpcan.so

to

arm-linux-androideabi-gcc src/libpcan.c -fPIC -shared -O2 -Wall -lc -I. -I../driver -DNO_RT -o -libpcan.so

This .so has the same size as the so.0.6 so i assume it worked fine.

My own c-code is getting compiled with

arm-linux-androideabi -shared src/receivetest.c src/common.c -I. -I../lib -I../driver -L../lib -L/lib -L/usr/lib -L/usr/local/lib -o libreceivetest.so

I load both of these files, so the libpcan.so and the libreceivetest.so to my app

    static {
    System.loadLibrary("pcan");
    System.loadLibrary("receivetest");
    }

When I'm trying to launch that app i get the error message:

 07-14 11:12:43.812: E/AndroidRuntime(753): java.lang.ExceptionInInitializerError
 07-14 11:12:43.812: E/AndroidRuntime(753): Caused by: java.lang.UnsatisfiedLinkError: Cannot load library: reloc_library[1306]:    36 cannot locate 'CAN_Open'...

My receivetest is using that function, but since it declared in the libpcan.so and im also loading that library, i don't know where that error could come from. I'd just guess its an error in my clags, since I'm new to building .so files via using gcc in the shell i don't really understand all the flags im using.

1条回答
\"骚年 ilove
2楼-- · 2019-08-12 06:53

It's quite long since i solved this. But I haven't ever marked this question as solved. Thanks to jww for reminding me.

As I've said in the comment to my question, the link to the function CAN_Open was missing due to a missing parameter at compiling the .so-file. The function CAN_Open is a part of the libpcan.so and by skipping the link to that file the CAN_Open function just never made it into the receivetest.so .

查看更多
登录 后发表回答