openssl build MSYS2

前文 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 mingw64/mingw-w64-x86_64-gcc
windows

刚开始编译时提示找不到gcc

添加环境变量
export PATH=$PATH:/mingw64/bin
$source /etc/profile

将openssl源码复制到C:\msys64\home\world下

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\n",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

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

源码移动到 C:\msys64\home\freem\openssl
 
 
 

猜你喜欢

转载自www.cnblogs.com/marklove/p/11869327.html