zoukankan      html  css  js  c++  java
  • NDK21编译openssl-1.1.1h

    在centos7下面使用android-ndk-r21d编译openssl-1.1.1h

    基本都是最新版本了,centos7需要安装一下perl,python

    yum -y install perl python

    接下来把android-ndk-r21d放到根目录 /android-ndk-r21d这样 如果其他路径记得自己改下面的脚本

    下载保存这个脚本 命名为toolchains_path.py

    #!/usr/bin/env python
    """
        Get the toolchains path
    """
    import argparse
    import atexit
    import inspect
    import os
    import shutil
    import stat
    import sys
    import textwrap
    
    def get_host_tag_or_die():
        """Return the host tag for this platform. Die if not supported."""
        if sys.platform.startswith('linux'):
            return 'linux-x86_64'
        elif sys.platform == 'darwin':
            return 'darwin-x86_64'
        elif sys.platform == 'win32' or sys.platform == 'cygwin':
            host_tag = 'windows-x86_64'
            if not os.path.exists(os.path.join(NDK_DIR, 'prebuilt', host_tag)):
                host_tag = 'windows'
            return host_tag
        sys.exit('Unsupported platform: ' + sys.platform)
    
    
    def get_toolchain_path_or_die(ndk, host_tag):
        """Return the toolchain path or die."""
        toolchain_path = os.path.join(ndk, 'toolchains/llvm/prebuilt',
                                      host_tag)
        if not os.path.exists(toolchain_path):
            sys.exit('Could not find toolchain: {}'.format(toolchain_path))
        return toolchain_path
    
    def main():
        """Program entry point."""
        parser = argparse.ArgumentParser(description='Optional app description')
        parser.add_argument('--ndk', required=True,
                        help='The NDK Home directory')
        args = parser.parse_args()
    
        host_tag = get_host_tag_or_die()
        toolchain_path = get_toolchain_path_or_die(args.ndk, host_tag)
        print toolchain_path
    
    if __name__ == '__main__':
        main()

    然后保存下面的脚本 

    #!/bin/bash
    set -e
    set -x
    
    # Set directory
    SCRIPTPATH=$(pwd)
    dir=$(pwd)
    export ANDROID_NDK_HOME=/android-ndk-r21d
    OPENSSL_DIR=$SCRIPTPATH/openssl-1.1.1h
    
    # Find the toolchain for your build machine
    toolchains_path=$(python toolchains_path.py --ndk ${ANDROID_NDK_HOME})
    
    # Configure the OpenSSL environment, refer to NOTES.ANDROID in OPENSSL_DIR
    # Set compiler clang, instead of gcc by default
    CC=clang
    
    # Add toolchains bin directory to PATH
    PATH=$toolchains_path/bin:$PATH
    
    # Set the Android API levels
    ANDROID_API=21
    rm -rf $dir/output
    # Set the target architecture
    # Can be android-arm, android-arm64, android-x86, android-x86 etc
    cpus=( android-arm android-arm64 )
    for cur in ${cpus[*]};do
    architecture=$cur
    echo "--------cur=$architecture-------"
    cd $dir
    rm -rf openssl-1.1.1h
    tar -xf openssl-1.1.1h.tar.gz
    # Create the make file
    cd ${OPENSSL_DIR}
    ./Configure ${architecture} -D__ANDROID_API__=$ANDROID_API
    
    # Build
    make
    
    # Copy the outputs
    OUTPUT_LIB=$SCRIPTPATH/output/lib/${architecture}
    mkdir -p $OUTPUT_LIB
    cp libcrypto.so $OUTPUT_LIB
    cp libcrypto.a $OUTPUT_LIB
    cp libssl.so $OUTPUT_LIB
    cp libssl.a $OUTPUT_LIB
    done
    
    OUTPUT_INCLUDE=$SCRIPTPATH/output/include
    mkdir -p $OUTPUT_INCLUDE
    cp -RL include/openssl $OUTPUT_INCLUDE

    运行这个脚本 会在当前目录生产output里面有库和头文件

    本文基本来源于https://blog.csdn.net/iamadk/article/details/97155757

  • 相关阅读:
    leetcode Super Ugly Number
    leetcode Find Median from Data Stream
    leetcode Remove Invalid Parentheses
    leetcode Range Sum Query
    leetcode Range Sum Query
    leetcode Minimum Height Trees
    hdu 3836 Equivalent Sets
    hdu 1269 迷宫城堡
    hud 2586 How far away ?
    poj 1330 Nearest Common Ancestors
  • 原文地址:https://www.cnblogs.com/yuandaozhe/p/14372844.html
Copyright © 2011-2022 走看看