Sophie

Sophie

distrib > Mageia > 6 > i586 > by-pkgid > f93881942bd3805980c2fe63aa853d78 > files > 186

qtdoc5-5.9.4-1.mga6.noarch.rpm

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html>
<html lang="en">
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<!-- android.qdoc -->
  <title>Adding OpenSSL Support for Android | Qt 5.9</title>
  <link rel="stylesheet" type="text/css" href="style/offline-simple.css" />
  <script type="text/javascript">
    document.getElementsByTagName("link").item(0).setAttribute("href", "style/offline.css");
    // loading style sheet breaks anchors that were jumped to before
    // so force jumping to anchor again
    setTimeout(function() {
        var anchor = location.hash;
        // need to jump to different anchor first (e.g. none)
        location.hash = "#";
        setTimeout(function() {
            location.hash = anchor;
        }, 0);
    }, 0);
  </script>
</head>
<body>
<div class="header" id="qtdocheader">
  <div class="main">
    <div class="main-rounded">
      <div class="navigationbar">
        <table><tr>
<td ><a href="index.html">Qt 5.9</a></td><td >Adding OpenSSL Support for Android</td></tr></table><table class="buildversion"><tr>
<td id="buildversion" width="100%" align="right">Qt 5.9.4 Reference Documentation</td>
        </tr></table>
      </div>
    </div>
<div class="content">
<div class="line">
<div class="content mainContent">
<div class="sidebar"><div class="sidebar-content" id="sidebar-content"></div></div>
<h1 class="title">Adding OpenSSL Support for Android</h1>
<span class="subtitle"></span>
<!-- $$$opensslsupport.html-description -->
<div class="descr"> <a name="details"></a>
<p>The Qt installation package comes with OpenSSL support but the OpenSSL libraries are not part of the package due to legal restrictions in some countries. If your application depends on OpenSSL, consider packaging the SSL libraries with your Application Package (APK) as the target device may or may not have them. You can use the QSslSocket::supportsSsl() static function to check for SSL support on the target.</p>
<p>The following instructions guide you to build and add the OpenSSL libraries to the APK:</p>
<ol class="1" type="1"><li>Download the <a href="https://wiki.openssl.org/images/7/70/Setenv-android.sh">setup script</a> to configure the build environment.<p><b>Note: </b>Ensure that you save the script with Unix line-endings if your build host is Unix or Linux.</p></li>
<li>Make the following changes in the setup script:<ul>
<li>Set appropriate values to the <code>_ANDROID_EABI</code> and <code>_ANDROID_ARCH</code> variables. For example, to build for 64-bit ARM architecture using toolchain version v4.9, set <code>aarch64-linux-android-4.9</code> and <code>arch-arm64</code> values to <code>_ANDROID_EABI</code> and <code>_ANDROID_ARCH</code> respectively.</li>
<li>Add the <code>windows-x86</code> or <code>windows-x86_64</code> to the <code>hosts</code> list on line <code>107</code>, if your build host is Windows.</li>
<li>Add the following after line <code>128</code> to build for 64-bit ARM architecture:<pre class="cpp plain">

    arch-arm64)
  ANDROID_TOOLS=&quot;aarch64-linux-android-gcc aarch64-linux-android-ranlib aarch64-linux-android-ld&quot;
      ;;

</pre>
</li>
<li>Add the following after line <code>213</code> if <code>_ANDROID_ARCH</code> is set to <code>arch-arm64</code>:<pre class="cpp plain">

  if [ &quot;$_ANDROID_ARCH&quot; == &quot;arch-arm64&quot; ]; then
          export MACHINE=armv8
          export RELEASE=2.6&#x2e;37
          export SYSTEM=android64
          export ARCH=arm
          export CROSS_COMPILE=&quot;aarch64-linux-android-&quot;
  fi

</pre>
</li>
<li>Comment out the <code>FIPS</code> section if it is not used or define the <code>FIPS_SIG</code> environment variable with the FIPS signature location.</li>
</ul>
</li>
<li>Define <code>ANDROID_NDK_ROOT</code> environment variable with the NDK location.</li>
<li>Provide executable rights for the setup script and run it:<pre class="cpp plain">

  chmod a+x Setenv-android.sh
  . &#x2e;/Setenv-android.sh

</pre>
<p>The script prints the following configuration details to the prompt when it completes:</p>
<pre class="cpp plain">

  ANDROID_NDK_ROOT: /home/user1/android-ndk-r10d
  ANDROID_ARCH: arch-arm64
  ANDROID_EABI: aarch64-linux-android-4.9
  ANDROID_API: android-21
  ANDROID_SYSROOT: /home/user1/android-ndk-r10d/platforms/android-21/arch-arm64
  ANDROID_TOOLCHAIN: /home/user1/android-ndk-r10d/toolchains/aarch64-linux-android-4.9/prebuilt/linux-x86_64/bin
  FIPS_SIG:
  CROSS_COMPILE: aarch64-linux-androideabi-
  ANDROID_DEV: /home/user1/android-ndk-r10d/platforms/android-21/arch-arm64/usr

</pre>
</li>
<li>Download the latest OpenSSL sources from <a href="http://www.openssl.org/source">http://www.openssl.org/source</a>.</li>
<li>Extract the sources to a folder and navigate to that folder using the CLI.<p><b>Note: </b>If your development platform is Windows, you need <code>msys</code> with <code>perl</code> v5.14 or later to build OpenSSL.</p></li>
<li>Configure the OpenSSL sources to build for Android using the following command:<pre class="cpp plain">

  ./Configure shared android

</pre>
<p><b>Note: </b>You must consider enabling/disabling the SSL features based on the legal restrictions in the region where your application is available. See the <a href="http://wiki.openssl.org/index.php/Compilation_and_Installation#Configure_Options">SSL configure options</a> for details about the configurable features.</p></li>
<li>Run <code>make CALC_VERSIONS=&quot;SHLIB_COMPAT=; SHLIB_SOVER=&quot; build_libs</code> to build the <code>libcrypto</code> and <code>libssl</code> shared libraries that are not versioned.<p><b>Note: </b>Android does not load versioned libraries.</p></li>
<li>Open your Qt project using Qt Creator and update the &quot;Build Android APK&quot; settings to add <i>libcrypto</i> and <i>libssl</i> as additional libraries for your project.</li>
<li>Run your application to see it running on the device.</li>
</ol>
<p>Qt Creator builds your application and creates an application package (APK) with the OpenSSL libraries bundled in it. Once the APK is ready, it uses <code>adb</code> to deploy the APK on the target you chose and launch the application.</p>
</div>
<!-- @@@opensslsupport.html -->
        </div>
       </div>
   </div>
   </div>
</div>
<div class="footer">
   <p>
   <acronym title="Copyright">&copy;</acronym> 2017 The Qt Company Ltd.
   Documentation contributions included herein are the copyrights of
   their respective owners.<br>    The documentation provided herein is licensed under the terms of the    <a href="http://www.gnu.org/licenses/fdl.html">GNU Free Documentation    License version 1.3</a> as published by the Free Software Foundation.<br>    Qt and respective logos are trademarks of The Qt Company Ltd.     in Finland and/or other countries worldwide. All other trademarks are property
   of their respective owners. </p>
</div>
</body>
</html>