Adding openssl library to apk



  • 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.



  • 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



  • 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



  • 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?


  • Moderators

    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.



  • 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. 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).


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.