Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. Adding openssl library to apk
Forum Updated to NodeBB v4.3 + New Features

Adding openssl library to apk

Scheduled Pinned Locked Moved Mobile and Embedded
7 Posts 4 Posters 7.3k Views 1 Watching
  • 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.
  • T Offline
    T Offline
    thesourcehim
    wrote on last edited by
    #1

    Hello. I'm trying to build an application for android that uses https urls in QNetworkRequest. I have built openssl library but how do add it to apk using qt-creator? It seems to only add Qt libraries there.

    1 Reply Last reply
    0
    • M Offline
      M Offline
      Moster
      wrote on last edited by
      #2

      I dont know, but maybe it works like I did it with sI added them manually to the pro file. You can rightclick in the pro file and click "Add library", then external library. There you can add the lib and include files, in case they exist. Platform should be none I guess

      1 Reply Last reply
      0
      • T Offline
        T Offline
        thesourcehim
        wrote on last edited by
        #3

        No, that didn't work. It only added external link dependency. The problem is application doesn't need openssl at build-time, it loads it dynamically at run-time. Perhaps I'll have to create separate apk for openssl

        1 Reply Last reply
        0
        • T Offline
          T Offline
          thesourcehim
          wrote on last edited by
          #4

          A was able to add libs to apk by copying library files into projects folder and adding the following to the .pro file:

          android: {
          ssl.files += libssl.so libcrypto.so

          ssl.path=/libs/$$ARCH
          
          INSTALLS+=ssl
          QMAKE_BUNDLE_DATA+=ssl
          

          }
          set ARCH variable in qmake command line.

          However https still doesn't work. The error text is 'Unknown protocol "https"'. Is there any support for SSL in android version of Qt?

          1 Reply Last reply
          0
          • raven-worxR Offline
            raven-worxR Offline
            raven-worx
            Moderators
            wrote on last edited by
            #5

            are you sure your Qt android version is built with OpenSSL support.
            I think it is disabled by default! So you'll have to build it yourself.
            You may also find "this":https://bugreports.qt-project.org/browse/QTBUG-29060 and "this":https://bugreports.qt-project.org/browse/QTBUG-32508 bugreport interesting.

            --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
            If you have a question please use the forum so others can benefit from the solution in the future

            1 Reply Last reply
            0
            • F Offline
              F Offline
              fbonin
              wrote on last edited by
              #6

              To clarify this situation, I have few questions:

              1/ Precompiled version of Qt 5.1 SDK for Android (those downloaded from http://qt-project.org/downloads) doesn't include OpenSSL supports?

              2/ If not, shall we built Qt 5.1 SDK for Android ourself, following http://qt-project.org/wiki/Qt5ForAndroidBuilding instructions and simply add flag "-openssl" on configure command line?

              3/ Is resulting Qt 5.1 SDK for Android will contain an Android version of OpenSsl that will be "automatically" embedded in any Application .apk package that need it ?

              1 Reply Last reply
              0
              • T Offline
                T Offline
                thesourcehim
                wrote on last edited by
                #7
                1. It is compiled without ssl support because of law issues in some countries

                2. -openssl flag for configure will enable dynamic openssl support (i.e. you don't need openssl headers/libs to build qt, but you will need to carry libopenssl.so with your application inside the package), you can also set -openssl-linked flag to link qt with libssl (in that case you'll need to install openssl in a separate package to system lib directory). However both methods will probably require qt source from git (last time I checked it was version 5.1.2) due to bug in 5.1.0 (not sure if 5.1.1 still has it) preventing ssl support to compile successfully. Also note that some modules, though included to build by configure script (like serialport), will not compile, you'll need to disable them manually. If you need to build qt for mips you'll have to disable even more modules.

                3. No it won't. You'll have to build openssl for android yourself from source:
                  https://github.com/guardianproject/openssl-android
                  It's also a bit tricky, if you're building for x86 or mips, you'll have to add -lz linker flag manually. After that you'll have to manually add libssl.so and libcrypto.so to your application package (it must be in libs directory).

                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