Linking with versioned shared library in Android NDK

后端 未结 3 1981
我在风中等你
我在风中等你 2021-02-04 18:57

I am trying to load two shared libraries in my Android application through the loadLibrary call:

System.loadLibrary(\"mywrapper\");
System.loadLibra         


        
3条回答
  •  误落风尘
    2021-02-04 19:30

    I had the same problem on building libwebsockets for Android, which needs to link with OpenSSL. I use libssl.so as example. You should do the same for related .so files.

    Before:
    huiying@huiying-PORTEGE-R835:~$ objdump -p libssl.so | grep so
    libssl.so:     file format elf32-little
      NEEDED               libcrypto.so.1.0.0
      NEEDED               libdl.so
      NEEDED               libc.so
      SONAME               libssl.so.1.0.0
    
    After 
    huiying@huiying-PORTEGE-R835:~$ rpl -R -e .so.1.0.0 "_1_0_0.so" libssl.so 
    Replacing ".so.1.0.0" with "_1_0_0.so" (case sensitive) (partial words matched)
    .
    A Total of 2 matches replaced in 1 file searched.
    huiying@huiying-PORTEGE-R835:~$ objdump -p libssl.so | grep so
    libssl.so:     file format elf32-little
      NEEDED               libcrypto_1_0_0.so
      NEEDED               libdl.so
      NEEDED               libc.so
      SONAME               libssl_1_0_0.so
    
    And don't forget to change file name "libssl.so" to "libssl_1_0_0.so".

    The hack works. I have running Android app to prove it. See my rant at http://computervisionandjava.blogspot.com/2015/05/trouble-with-versioned-shared-libraries.html.

提交回复
热议问题