UnsatisfiedLinkError:找不到libcrypto.so.1.0.0 [英] UnsatisfiedLinkError: libcrypto.so.1.0.0 not found

查看:140
本文介绍了UnsatisfiedLinkError:找不到libcrypto.so.1.0.0的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Eclipse中使用android ndk.我已经编译了项目,但是在运行时遇到了错误.我有libcrytpoNative.solibsslNative.so文件,但是却遇到有关libcrypto.so.1.0.0 not found错误的错误.我该如何解决?

I am using android ndk in eclipse. I got my project compiled but am facing errors at run time. I have the libcrytpoNative.so and libsslNative.so files but I am getting this error about libcrypto.so.1.0.0 not found error. How should I fix this?

这是ndk-build V=1

    Android NDK: WARNING: APP_PLATFORM android-21 is larger than android:minSdkVersion 14 in ./AndroidManifest.xml    
    rm -f ./libs/arm64-v8a/lib*.so ./libs/armeabi/lib*.so ./libs/armeabi-v7a/lib*.so ./libs/armeabi-v7a-hard/lib*.so ./libs/mips/lib*.so ./libs/mips64/lib*.so ./libs/x86/lib*.so ./libs/x86_64/lib*.so
    rm -f ./libs/arm64-v8a/gdbserver ./libs/armeabi/gdbserver ./libs/armeabi-v7a/gdbserver ./libs/armeabi-v7a-hard/gdbserver ./libs/mips/gdbserver ./libs/mips64/gdbserver ./libs/x86/gdbserver ./libs/x86_64/gdbserver
    rm -f ./libs/arm64-v8a/gdb.setup ./libs/armeabi/gdb.setup ./libs/armeabi-v7a/gdb.setup ./libs/armeabi-v7a-hard/gdb.setup ./libs/mips/gdb.setup ./libs/mips64/gdb.setup ./libs/x86/gdb.setup ./libs/x86_64/gdb.setup
    [armeabi-v7a] Install        : libcpabe.so => libs/armeabi-v7a/libcpabe.so
    install -p ./obj/local/armeabi-v7a/libcpabe.so ./libs/armeabi-v7a/libcpabe.so
    /home/yogi/android-ndk/toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64/bin/arm-linux-androideabi-strip --strip-unneeded  ./libs/armeabi-v7a/libcpabe.so
    [armeabi-v7a] Install        : libcryptoNative.so => libs/armeabi-v7a/libcryptoNative.so
    install -p ./obj/local/armeabi-v7a/libcryptoNative.so ./libs/armeabi-v7a/libcryptoNative.so
    /home/yogi/android-ndk/toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64/bin/arm-linux-androideabi-strip --strip-unneeded  ./libs/armeabi-v7a/libcryptoNative.so
    [armeabi-v7a] Install        : libglib.so => libs/armeabi-v7a/libglib.so
    install -p ./obj/local/armeabi-v7a/libglib.so ./libs/armeabi-v7a/libglib.so
    /home/yogi/android-ndk/toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64/bin/arm-linux-androideabi-strip --strip-unneeded  ./libs/armeabi-v7a/libglib.so
    [armeabi-v7a] Install        : libgmp.so => libs/armeabi-v7a/libgmp.so
    install -p ./obj/local/armeabi-v7a/libgmp.so ./libs/armeabi-v7a/libgmp.so
    /home/yogi/android-ndk/toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64/bin/arm-linux-androideabi-strip --strip-unneeded  ./libs/armeabi-v7a/libgmp.so
    [armeabi-v7a] Install        : libpbc.so => libs/armeabi-v7a/libpbc.so
    install -p ./obj/local/armeabi-v7a/libpbc.so ./libs/armeabi-v7a/libpbc.so
    /home/yogi/android-ndk/toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64/bin/arm-linux-androideabi-strip --strip-unneeded  ./libs/armeabi-v7a/libpbc.so
    [armeabi-v7a] Install        : libsslNative.so => libs/armeabi-v7a/libsslNative.so
    install -p ./obj/local/armeabi-v7a/libsslNative.so ./libs/armeabi-v7a/libsslNative.so
    /home/yogi/android-ndk/toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64/bin/arm-linux-androideabi-strip --strip-unneeded  ./libs/armeabi-v7a/libsslNative.so

这是加载库的MainActivity.java:

This is the MainActivity.java that loads libs:

打包com.example.myproject;

package com.example.myproject;

import android.app.Activity;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.widget.TextView;

public class MainActivity extends Activity {

    static {
        System.loadLibrary("gmp");             
//        System.loadLibrary("ssl");
//        System.loadLibrary("crypto");
        System.loadLibrary("glib");
        System.loadLibrary("pbc"); 
        System.loadLibrary("sslNative");
        System.loadLibrary("cryptoNative");
        System.loadLibrary("cpabe");          
    }

    //System.loadLibrary("ssl_static");


    public static native void InitMainActivityjni();
    public native String cpabeNative();

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        //setContentView(R.layout.activity_main);
        TextView  tv = new TextView(this);
        tv.setText(cpabeNative());
        setContentView(tv);
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.main, menu);
        return true;
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        // Handle action bar item clicks here. The action bar will
        // automatically handle clicks on the Home/Up button, so long
        // as you specify a parent activity in AndroidManifest.xml.
        int id = item.getItemId();
        if (id == R.id.action_settings) {
            return true;
        }
        return super.onOptionsItemSelected(item);
    }

}

谢谢

推荐答案

我遇到了类似的问题. Android不喜欢版本化的库文件,在这种情况下,仅更改.so lib的文件名是不可行的.您可以通过运行readelf来查看分配给库的实际名称的一个不错的技巧(如果您的.so文件为elf格式,如果不是,请参见

I had a similar problem. Android does not like versioned library files, and changing the file name of the .so lib alone will not do in this case. A nice trick you can do to see the actual name assigned to the library is by running readelf (if your .so file is in elf format, if not, see this post for other options).

运行此命令后,您将需要查找出现在DEPEND& SONAME.如果您看到版本化的.so.1.0.0名称,请继续阅读,救恩就在附近:)

Once you run this, you will need to look for items appearing under DEPEND & SONAME. If you see the versioned .so.1.0.0 name, then keep on reading, salvation is near :)

现在,您基本上有两种选择-重新编译libcrypto.so&再次libssl.so,这一次添加了适当的标志,以防止它附加版本后缀,或者编辑libs以删除版本后缀.我将展示如何执行第二个选项.

Now, you basically have two choices - either recompile your libcrypto.so & libssl.so again, this time adding the appropriate flags preventing it from appending the version suffix, or edit the libs to remove the version suffix. I will show how to to do the 2nd option.

确保已安装rpl命令行工具.如果不是,请运行:

Ensure you have the rpl command line tool installed. If it isnt, run:

brew install rpl

您可能需要使用sudo运行它.

You might need to run this with sudo.

安装此工具后,您将需要使用它来编辑ssl&像这样的加密库:

Once this tool is installed, you will need to use it to edit the symbols in both the ssl & crypto libraries like so:

rpl -R -e .so.1.0.0 "_1_0_0.so" /path/to/libssl.so
rpl -R -e .so.1.0.0 "_1_0_0.so" /path/to/libcrypto.so

快完成了!

再次运行readelf工具,以确保正确更改了符号.现在剩下要做的唯一一件事就是将实际文件名更改为libssl_1_0_0.so& ;; libcrypto_1_0_0.so,并且在加载库时,请确保使用调整后的文件名:

Run the readelf tool again to make sure the symbols have been properly changed. The only thing left to do now is to change the actual file names to libssl_1_0_0.so & libcrypto_1_0_0.so, and when loading the library, make sure to use the adjusted file names:

System.loadLibrary("ssl_1_0_0");
System.loadLibrary("crypto_1_0_0");

现在一切正常.希望这能解决您的问题.

Things should work now. Hope this solves your problem.

这篇关于UnsatisfiedLinkError:找不到libcrypto.so.1.0.0的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆