Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Installation and Deployment
  4. Android build issues with OpenSSL on 5.0/5.1
QtWS25 Last Chance

Android build issues with OpenSSL on 5.0/5.1

Scheduled Pinned Locked Moved Solved Installation and Deployment
androidpyqtopenssl
7 Posts 3 Posters 2.6k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • K Offline
    K Offline
    kviktor
    wrote on last edited by kviktor
    #1

    When I try to start my application on an Android phone running 5.0 or 5.1 I get the following error, on version 6.0/7.0 the application starts/works just fine. I have tried NDK r10e and Crystax, but both have the same issue.

    E/art     (18856): dlopen("/data/app/org.qtproject.example-1/lib/arm/libMyName.so", RTLD_LAZY) failed: dlopen failed: cannot locate symbol "RSA_generate_key" referenced by "libMyName.so"...
    D/AndroidRuntime(18856): Shutting down VM
    E/AndroidRuntime(18856): FATAL EXCEPTION: main
    E/AndroidRuntime(18856): Process: org.qtproject.example, PID: 18856
    E/AndroidRuntime(18856): java.lang.UnsatisfiedLinkError: dlopen failed: cannot locate symbol "RSA_generate_key" referenced by "libMyName.so"...
    E/AndroidRuntime(18856): 	at java.lang.Runtime.loadLibrary(Runtime.java:371)
    E/AndroidRuntime(18856): 	at java.lang.System.loadLibrary(System.java:988)
    E/AndroidRuntime(18856): 	at org.qtproject.qt5.android.bindings.QtLoader.loadApplication(QtLoader.java:245)
    E/AndroidRuntime(18856): 	at org.qtproject.qt5.android.bindings.QtLoader.startApp(QtLoader.java:655)
    E/AndroidRuntime(18856): 	at org.qtproject.qt5.android.bindings.QtActivityLoader.onCreate(QtActivityLoader.java:183)
    E/AndroidRuntime(18856): 	at org.qtproject.qt5.android.bindings.QtActivity.onCreateHook(QtActivity.java:266)
    E/AndroidRuntime(18856): 	at org.qtproject.qt5.android.bindings.QtActivity.onCreate(QtActivity.java:273)
    E/AndroidRuntime(18856): 	at android.app.Activity.performCreate(Activity.java:5990)
    E/AndroidRuntime(18856): 	at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1106)
    E/AndroidRuntime(18856): 	at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2278)
    E/AndroidRuntime(18856): 	at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2387)
    E/AndroidRuntime(18856): 	at android.app.ActivityThread.access$800(ActivityThread.java:151)
    E/AndroidRuntime(18856): 	at android.app.ActivityThread$H.handleMessage2(ActivityThread.java:1303)
    E/AndroidRuntime(18856): 	at android.os.Handler.dispatchMessage(Handler.java:102)
    E/AndroidRuntime(18856): 	at android.os.Looper.loop(Looper.java:135)
    E/AndroidRuntime(18856): 	at android.app.ActivityThread.main(ActivityThread.java:5254)
    E/AndroidRuntime(18856): 	at java.lang.reflect.Method.invoke(Native Method)
    E/AndroidRuntime(18856): 	at java.lang.reflect.Method.invoke(Method.java:372)
    E/AndroidRuntime(18856): 	at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903)
    E/AndroidRuntime(18856): 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)
    W/ActivityManager(  585):   Force finishing activity 1 org.qtproject.example/org.my.MyNameActivity
    

    I have these 2 in my .pro file so the library is added

    
    ANDROID_EXTRA_LIBS += /path/to/sysroot/lib/libcrypto.so
    ANDROID_EXTRA_LIBS += /path/to/sysroot/lib/libssl.so
    

    Also checking the .so file itself the function seems to be there

    ./arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/arm-linux-androideabi-readelf -all /path/to/sysroot/lib/libcrypto.so | grep RSA_generate_key
      1020: 0009c0f4  1504 FUNC    GLOBAL DEFAULT    7 RSA_generate_key_ex
      1084: 000a00fc   220 FUNC    GLOBAL DEFAULT    7 RSA_generate_key
      9625: 0009c0f4  1504 FUNC    GLOBAL DEFAULT    7 RSA_generate_key_ex
      9689: 000a00fc   220 FUNC    GLOBAL DEFAULT    7 RSA_generate_key
    

    Any idea what might be the issue? As I see 5.1 still has a lot of users.

    Also I'm using PyQt with a modified Python install (which uses that function) but it still seems weird that 5.1 fails and 6.0 works.

    1 Reply Last reply
    0
    • sierdzioS Offline
      sierdzioS Offline
      sierdzio
      Moderators
      wrote on last edited by
      #2

      The problem is that Android 5 ships with a default build of old OpenSSL release (something around 1.0.0). Since these are system libs, they get picked up before your .so files. And that's why you get a missing symbol - because wrong OpenSSL was loaded by the Android system.

      I did solve this issue once, but I don't remember how, I'll try to find my solution and come back here :-)

      (Z(:^

      1 Reply Last reply
      2
      • K Offline
        K Offline
        kviktor
        wrote on last edited by
        #3

        I implemented my custom function using RSA_generate_key_ex instead and the application works now (I'm guessing the OpenSSL on Android 5.0 was built without deprecated functions).

        This is kind of a workaround of the original issue tho, if you find your old solution please share :)

        sierdzioS 1 Reply Last reply
        1
        • K kviktor

          I implemented my custom function using RSA_generate_key_ex instead and the application works now (I'm guessing the OpenSSL on Android 5.0 was built without deprecated functions).

          This is kind of a workaround of the original issue tho, if you find your old solution please share :)

          sierdzioS Offline
          sierdzioS Offline
          sierdzio
          Moderators
          wrote on last edited by sierdzio
          #4

          @kviktor said in Android build issues with OpenSSL on 5.0/5.1:

          if you find your old solution please share :)

          Uh... I just did. Turns out that the function which was missing for me was not really necessary so I removed it. So in that sense it's the same solution you used.

          As far as I know there are 2 proper solutions:

          • recompile Qt with custom (static) OpenSSL build and use it to build your project (make sure you only link to OpenSSL statically)
          • create a custom wrapper for OpenSSL functions you need, link it statically to OpenSSL and to your app

          (Z(:^

          K M 2 Replies Last reply
          1
          • sierdzioS sierdzio

            @kviktor said in Android build issues with OpenSSL on 5.0/5.1:

            if you find your old solution please share :)

            Uh... I just did. Turns out that the function which was missing for me was not really necessary so I removed it. So in that sense it's the same solution you used.

            As far as I know there are 2 proper solutions:

            • recompile Qt with custom (static) OpenSSL build and use it to build your project (make sure you only link to OpenSSL statically)
            • create a custom wrapper for OpenSSL functions you need, link it statically to OpenSSL and to your app
            K Offline
            K Offline
            kviktor
            wrote on last edited by
            #5

            For anyone finding this thread via Google OpenSSL actually has a somewhat detailed description about the workaround: https://wiki.openssl.org/index.php/Android#Wrapper_Shared_Objects

            1 Reply Last reply
            0
            • sierdzioS sierdzio

              @kviktor said in Android build issues with OpenSSL on 5.0/5.1:

              if you find your old solution please share :)

              Uh... I just did. Turns out that the function which was missing for me was not really necessary so I removed it. So in that sense it's the same solution you used.

              As far as I know there are 2 proper solutions:

              • recompile Qt with custom (static) OpenSSL build and use it to build your project (make sure you only link to OpenSSL statically)
              • create a custom wrapper for OpenSSL functions you need, link it statically to OpenSSL and to your app
              M Offline
              M Offline
              mkre
              wrote on last edited by
              #6

              @sierdzio Is there a guide for either of these two solutions? Running into this issue now for an APK I'm trying to build for an Android 5.0/5.1 device that uses QNetworkRequest to download files from the internet.

              sierdzioS 1 Reply Last reply
              0
              • M mkre

                @sierdzio Is there a guide for either of these two solutions? Running into this issue now for an APK I'm trying to build for an Android 5.0/5.1 device that uses QNetworkRequest to download files from the internet.

                sierdzioS Offline
                sierdzioS Offline
                sierdzio
                Moderators
                wrote on last edited by
                #7

                @mkre said in Android build issues with OpenSSL on 5.0/5.1:

                @sierdzio Is there a guide for either of these two solutions? Running into this issue now for an APK I'm trying to build for an Android 5.0/5.1 device that uses QNetworkRequest to download files from the internet.

                Option 2 (workaround) is described in the linkg @kviktor posted, just above your comment.

                As for compiling Qt statically, look in Qt docs and output of ./configure --help. Please remember license (LGPL, GPL) limitations when compiling statically.

                (Z(:^

                1 Reply Last reply
                0

                • Login

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • Users
                • Groups
                • Search
                • Get Qt Extensions
                • Unsolved