zoukankan      html  css  js  c++  java
  • openssl build MSYS2

    https://github.com/openssl/openssl/issues/10459

    github 是否解决win下编译问题 提问

    linux交叉编译win

     第一步:安装mingw32

    本人 linux 环境是ubuntu18.04  

    sudo apt-get install mingw-w64
    sudo apt-get install mingw-w64-tools
    sudo apt-get install mingw-w64-i686-dev
    sudo apt-get install mingw-w64-x86-64-dev
    https://blog.csdn.net/zuihaobushi/article/details/90167362

    CROSS_COMPILE="x86_64-w64-mingw32-" ./Configure mingw64 no-asm shared --prefix=/opt/mingw64

    PATH=$PATH:/opt/mingw64/bin make

    sudo PATH=$PATH:/opt/mingw64/bin make install

    https://www.cnblogs.com/findumars/p/6372299.html

    http://www.blogcompiler.com/2011/12/21/openssl-for-windows/

    https://www.perl.org/

    msvc

    perl Configure --prefix="%CD%..MSVC64rdll" --openssldir="%CD%..MSVC64rdllssl" -EHsc -arch:AVX -FS threads no-deprecated shared VC-WIN64A && nmake
    ./Configure --prefix=$PWD/GCC32r shared mingw --unified && make depend && make && make install
    pacman -S base-devel msys2-devel mingw-w64-{x86_64,i686}-toolchain 

    perl Configure mingw64 no-shared --prefix=/d/Code/openssl-1.0.2a/build-x64-PT-seh

    ./Configure threads no-deprecated shared mingw64 >_Configure.log && make
    perl Configure -MTd threads no-deprecated no-shared debug-VC-WIN64A && nmake
      • '/MDd' for Debug+Shared build,
      • '/MD' for Release+Shared build,
      • '/MT' for Release+Static build,
        as expected according to its description. But for some reason it add
      • '/MT' and '/MDd' keys, instead of '/MTd', for Debug+Static build.
    ./Configure --prefix="$PWD/../GCC64d" -std=gnu11 -mtune=native -march=native threads no-deprecated shared debug-mingw64 >_Configure.log && ma ke 

    ./configure --prefix="$BASEDIR" --with-mibdirs="$BASEDIR/share/snmp/mibs" --with-mib-modules="agentx disman/event-mib winExtDLL " --disable-embedded-perl --without-perl-modules --enable-ipv6

    ./Configure --prefix="$PWD/../GCC64r" -std=gnu11 -mtune=native -march=native threads no-deprecated shared mingw64 && make

     perl Configure mingw64 --cross-compile-prefix=x86_64-w64-mingw32-

    Then I make with no problems:
    make

    Then I test:
    make test

        perl Configure VC-WIN64A shared --prefix=devopenssl-1.1.1 /FS
        jom -j 8
        perl Configure VC-WIN64A shared --prefix=devopenssl /FS
        jom -j 8
    perl Configure mingw no-shared no-asm --prefix=/c/OpenSSL
    make depend
    make 

     

     git config core.autocrlf false
    git rm --cached -r .
    git reset --hard

    git config --local core.autocrlf false
    git config --local core.eol lf

    git rm --cached -r .
    git reset --hard

    前文 git等各种源码仓库

    https://www.cnblogs.com/marklove/p/11831539.html

    x1
    >>
    O
     
     
     
     
     
     
    git clone https://github.com/openssl/openssl
    git submodule update --init --recursive
    ./configure mingw64 shared

    ./Configure mingw64 初始化配置 2

    pacman -S base-devel
    pacman -S mingw-w64-x86_64-toolchain
    /*pacman -S mingw64/mingw-w64-x86_64-gcc*/
    windows
    
    刚开始编译时提示找不到gcc
    
    添加环境变量
    export PATH=$PATH:/mingw64/bin
    $source /etc/profile
    
    将openssl源码复制到C:msys64homeworld下
    
    MSYS2 SHELL
    
    切换到
    
    /home/world/openssl
    
    ./Configure mingw64
    
    make
    
    ============================================
    
    ubuntu下
    
    进去openssl
    
    perl Configure gcc shared
    
    make

    常用软件包编译

    常用软件包我们可以简单的使用命令直接从官网安装即可,比如安装openssl:

    • 32bit:pacman -S mingw-w64-i686-openssl
    • 64bit: pacman -S mingw-w64-x86_64-openssl

    有时候根据项目需要我们不得不自己动手编译依赖的软件包,以下是我在工作用到的库编译过程记录。

    openssl

    • 64bit

      mkdir openssl64
      cd openssl64
      tar zxvf openssl-1.0.2c.tar.gz
      cd openssl-1.0.2c
      ./configure mingw64 shared
      make
      make INSTALL_PREFIX=../ install
    • 32bit

      mkdir openssl32
      cd openssl32
      tar zxvf openssl-1.0.2c.tar.gz
      cd openssl-1.0.2c
      ./configure mingw shared
      make
      make INSTALL_PREFIX=../ install

    zlib

      • 32bit 

        mkdir zlib32 
        cd zlib32 
        tar zxvf zlib-1.2.8.tar.gz 
        cd zlib-1.2.8/ 
        make -f ./win32/Makefile.gcc 
        make 
        make install -f win32/Makefile.gcc DESTDIR=../
    通常Linux系统自带OpenSSL,但是其so文件由于没有debug信息,因此无法跟踪内部函数,对于学习
    不太方便,需要通过源码重新安装。
            我的Linux系统是CentOS7,自带的OpenSSL的版本是1.0.1e。在网上下载了OpenSSL1.0.1f后,通过
    如下方法安装
    [html] view plain copy
     
    
        ./config --prefix=/usr/local --openssldir=/usr/local/ssl    
        make && make install    
        ./config -d shared --prefix=/usr/local --openssldir=/usr/local/ssl    
        make clean    
        make && make install    
    
    
            先安装静态库版本,再安装动态库版本。安装目录为/usr/local下。安装动态库时增加-d选项,因为
    调试时使用动态库,需要跟踪代码。
            这样后面就可以写调试代码调试,如下面的例子:
    
    #include <stdio.h>
    #include <string.h>
    #include <openssl/bio.h>
    int main()
    {
    BIO *b = NULL;
    int len = 0;
    char *out = NULL;
    b = BIO_new(BIO_s_mem());
     
    if (NULL == b)
    {
    return 0;
    }
     
    len = BIO_write(b,"openssl",4);
    len = BIO_printf(b,"%s","zcp");
    len = BIO_ctrl_pending(b);
     
    out = (char *)OPENSSL_malloc(len);
    if (NULL == out)
    {
    return 0;
    }
    memset(out, 0, len);
     
    len = BIO_read(b,out,len);
    printf("out is : %s
    ",out);
     
    OPENSSL_free(out);
    BIO_free(b);
    return 0;
    }
        在当前路径下创建一个新的动态库软链接:
        ln -s /usr/local/lib64/libcrypto.so.1.0.0  libcrypto.so.10
       然后gcc编译时指明使用这个libcrypto:
        gcc -g -DDEBUG -o openssl_mem_bio_test openssl_mem_bio_test.c -lcrypto -Wl,-rpath=.
    View Code
    问题1
     
    子模组 'boringssl'(https://boringssl.googlesource.com/boringssl)已对路径 'boringssl' 注册
    子模组 'krb5'(https://github.com/krb5/krb5)已对路径 'krb5' 注册
    子模组 'pyca.cryptography'(https://github.com/pyca/cryptography.git)已对路径 'pyca-cryptography' 注册
    正克隆到 '/d/2017-2019/2018-11-05-500G/ubuntu/iproject/openssl/openssl/boringssl'...
    fatal: 无法访问 'https://boringssl.googlesource.com/boringssl/':Connection timed out after 300002 milliseconds
    fatal: 无法克隆 'https://boringssl.googlesource.com/boringssl' 到子模组路径 '/d/2017-2019/2018-11-05-500G/ubuntu/iproject/openssl/openssl/boringssl'
    克隆 'boringssl' 失败。按计划重试
    正克隆到 '/d/2017-2019/2018-11-05-500G/ubuntu/iproject/openssl/openssl/krb5'...
     
    谷歌上不去 自己想办法
    问题2

    execvp:printf: Argument list too long

    getconf ARG_MAX
    xargs --show-limits 
    里面提到了使用xargs --show-limits 可以查看系统中对于参数长度的限制
    http://www.voidcn.com/article/p-wlonaiui-p.html
    如果使用Linux内核是足够你可以简单的做
    ulimit -s 100000

    将工作,因为Linux内核在10年前有一个补丁,改变参数限制基于堆栈大小: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=b6a2fea39318e43fee84fa7b0b90d68bed92d2ba

    更新:如果你觉得勇敢,你可以说

    ulimit -s unlimited

    与任何shell扩展,你会没事的,只要你有足够的内存。

    这是一个黑客。 你知道怎么设置堆栈限制吗? 这也会影响其他进程开始在同一个会话。

    是的,这是一个黑客。 大多数时候这种黑客是一次性(多长时间你手动移动大量的文件呢?)。 如果你确定这个过程不会吃你所有的内存,你可以设置

    ulimit - s无限 实际的命令行限制是2 ^ 31日或2 GB。 ( MAX_ARG_STRLEN 在内核源代码)。

    https://unix.stackexchange.com/questions/128559/solving-mv-argument-list-too-long

    文献https://github.com/imyller/meta-nodejs/issues/9

    源码移动到 C:msys64homefreemopenssl
     问题依旧。待解决 
     
     perl util/mkbuildinf.pl "gcc -m64 -Wall -O3 -DL_ENDIAN -DOPENSSL_PIC -DUNICODE -D_UNICODE -DWIN32_LEAN_AND_MEAN -D_MT -DNDEBUG" "mingw64" >
    perl的锅??
     make build_modules_nodep 能生成 libssl-3-x64.dll  libcrypto-3-x64.dll
     
    不需要的算法配置
     
    Ciphers:
    
    no-idea       -DOPENSSL_NO_IDEA
    no-aes        -DOPENSSL_NO_AES
    no-camellia   -DOPENSSL_NO_CAMELLIA
    no-seed       -DOPENSSL_NO_SEED
    no-bf         -DOPENSSL_NO_BF
    no-cast       -DOPENSSL_NO_CAST
    no-des        -DOPENSSL_NO_DES
    no-rc2        -DOPENSSL_NO_RC2
    no-rc4        -DOPENSSL_NO_RC4
    no-rc5        -DOPENSSL_NO_RC5
    
    no-md2        -DOPENSSL_NO_MD2
    no-md4        -DOPENSSL_NO_MD4
    no-md5        -DOPENSSL_NO_MD5
    no-sha        -DOPENSSL_NO_SHA
    no-ripemd     -DOPENSSL_NO_RIPEMD
    no-mdc2       -DOPENSSL_NO_MDC2
    
    no-rsa        -DOPENSSL_NO_RSA
    no-dsa        -DOPENSSL_NO_DSA
    no-dh         -DOPENSSL_NO_DH
    
    no-ec         -DOPENSSL_NO_EC
    no-ecdsa      -DOPENSSL_NO_ECDSA
    no-ecdh       -DOPENSSL_NO_ECDH
    
    Non-cipher functionality:
    
    no-sock       -DOPENSSL_NO_SOCK         No socket code.
    no-ssl2       -DOPENSSL_NO_SSL2         No SSLv2.
    no-ssl3       -DOPENSSL_NO_SSL3         No SSLv3.
    no-err        -DOPENSSL_NO_ERR          No error strings.
    no-krb5       -DOPENSSL_NO_KRB5         No Kerberos v5.
    no-engine     -DOPENSSL_NO_ENGINE       No dynamic engines.
    no-hw         -DOPENSSL_NO_HW           No support for external hardware.
    
    Not documented:
    
    no-tlsext     -DOPENSSL_NO_TLSEXT
    no-cms        -DOPENSSL_NO_CMS
    no-jpake      -DOPENSSL_NO_JPAKE
    no-capieng    -DOPENSSL_NO_CAPIENG
    ./config no-idea no-aes no-camellia no-seed no-bf no-cast no-des no-rc2 no-rc4 no-rc5 
    no-md2 no-md4 no-ripemd no-mdc2 no-rsa no-dsa no-dh no-ec no-ecdsa no-ecdh no-sock 
    no-ssl2 no-ssl3 no-err no-krb5 no-engine no-hw
    make depend
    make build_crypto
     
    x1
    >>
    O
    x1
    x1
    >>
    O
    x1
    x1
    >>
    O
    x1
    x1
    >>
    O
    x1
    x1
    >>
    O
    x1
    x1
    >>
    O
    x1
    x1
    >>
    O
    x1
    x1
    >>
    O
    x1
    x1
    >>
    O
    x1
    x1
    >>
    O
    x1
    x1
    >>
    O
    x1
    x1
    >>
    O
    x1
    x1
    >>
    O
    x1
  • 相关阅读:
    图像检索(image retrieval)- 11
    图像检索(image retrieval)- 10相关
    Mock.js简易教程,脱离后端独立开发,实现增删改查功能
    Azure Monitor (3) 对虚拟机磁盘设置自定义监控
    Azure Monitor (1) 概述
    Azure SQL Managed Instance (2) 备份SQL MI
    Azure Virtual Network (17) Private Link演示
    Azure Virtual Network (16) Private Link
    Azure Virtual Network (15) Service Endpoint演示
    Azure Virtual Network (14) Service Endpoint服务终结点
  • 原文地址:https://www.cnblogs.com/marklove/p/11869327.html
Copyright © 2011-2022 走看看