在32位平台上编译OpenSSL 1.1.1g MSYS2-失败

问题描述

我正在尝试构建1.1.1g的OpenSSL。 我已经在MSYS2和MinGW64下尝试过。

我该如何解决

MSys2构建:

cd '${workspace_loc:/${project_name}}'; \
export MSYS=/D/msys64; \
export CC=' \
/D/msys64/mingw32/bin/gcc.exe -D_WIN32 -m32 -static \
-L/usr/lib \
'; \
export PATH=\
:/d/msys64/mingw32/i686-w64-mingw32/bin:\
:/d/msys64/mingw32/bin:\
:/usr/local/bin:\
perl Configure mingw shared no-hw no-asm no-md2 --prefix=`pwd` --openssldir=`pwd`; \
echo make depend; make; \
echo mingw32-make depend; mingw32-make; \
make Makefile openssl.pc libssl.pc libcrypto.pc build_libs build_apps build_tools

输出

Configuring OpenSSL version 1.1.1g (0x1010107fL) for mingw
Using os-specific seed configuration
Creating configdata.pm
Creating Makefile

**********************************************************************
***                                                                ***
***   OpenSSL has been successfully configured                     ***
***                                                                ***
***   If you encounter a problem while building,please open an    ***
***   issue on GitHub <https://github.com/openssl/openssl/issues>  ***
***   and include the output from the following command:           ***
***                                                                ***
***       perl configdata.pm --dump                                ***
***                                                                ***
***   (If you are new to OpenSSL,you might want to consult the    ***
***   'Troubleshooting' section in the INSTALL file first)         ***
***                                                                ***
**********************************************************************
make depend
perl "-I." -Mconfigdata "util/dofile.pl" \
    "-omakefile" include/crypto/bn_conf.h.in > include/crypto/bn_conf.h
perl "-I." -Mconfigdata "util/dofile.pl" \
    "-omakefile" include/crypto/dso_conf.h.in > include/crypto/dso_conf.h
perl "-I." -Mconfigdata "util/dofile.pl" \
    "-omakefile" include/openssl/opensslconf.h.in > include/openssl/opensslconf.h
make depend && make _all
make[1]: Entering directory '/d/Develop/WorkspaceCCpp/openssl-1.1.1g'
make[1]: Leaving directory '/d/Develop/WorkspaceCCpp/openssl-1.1.1g'
make[1]: Entering directory '/d/Develop/WorkspaceCCpp/openssl-1.1.1g'
perl util/mkbuildinf.pl " /D/msys64/mingw32/bin/gcc.exe -D_WIN32 -m32 -static -L/usr/lib  -m32 -Wall
 -O3 -fomit-frame-pointer -DL_ENDIAN -DOPENSSL_PIC -DUNICODE -D_UNICODE -DWIN32_LEAN_AND_MEAN -D_MT 
-DOPENSSL_USE_APPLINK -DNDEBUG" "mingw" > crypto/buildinf.h
/D/msys64/mingw32/bin/gcc.exe -D_WIN32 -m32 -static -L/usr/lib   -I. -Iinclude -Icrypto -m32 -Wall -
O3 -fomit-frame-pointer -DL_ENDIAN -DOPENSSL_PIC -DOPENSSLDIR="\"/d/Develop/WorkspaceCCpp/openssl-1.
1.1g\"" -DENGInesDIR="\"/d/Develop/WorkspaceCCpp/openssl-1.1.1g/lib/engines-1_1\"" -DUNICODE -D_UNIC
ODE -DWIN32_LEAN_AND_MEAN -D_MT -DOPENSSL_USE_APPLINK -DNDEBUG  -MMD -MF crypto/cversion.d.tmp -MT c
rypto/cversion.o -c -o crypto/cversion.o crypto/cversion.c
In file included from D:/msys64/mingw32/i686-w64-mingw32/include/crtdefs.h:10,from D:/msys64/mingw32/i686-w64-mingw32/include/stddef.h:7,from D:/msys64/mingw32/lib/gcc/i686-w64-mingw32/10.1.0/include/stddef.h:1,from /mingw32/include/stdlib.h:55,from include/internal/cryptlib.h:13,from crypto/cversion.c:10:
D:/msys64/mingw32/i686-w64-mingw32/include/corecrt.h:128:18: error: expected ';' before 'typedef'
  128 | __MINGW_EXTENSION typedef __int64 __time64_t;
      |                  ^~~~~~~~
      |                  ;
In file included from /mingw32/include/time.h:45,from include/openssl/crypto.h:15,from include/internal/cryptlib.h:22,from crypto/cversion.c:10:
/mingw32/include/sys/types.h:149:23: error: conflicting types for 'time_t'
  149 |    typedef __time32_t time_t;
      |                       ^~~~~~
...
...
...
D:/msys64/mingw32/i686-w64-mingw32/include/corecrt.h:143:20: note: prevIoUs declaration of 'time_t' 
was here
  143 | typedef __time64_t time_t;
      |                    ^~~~~~
make: *** [Makefile:2406: crypto/cversion.o] Error 1

解决方法

一种解决方案是不要在MSys2下构建,而是选择MinGW64。 然后...

\mingw64\mingw32\msys\1.0\bin\bash.exe

然后...

(1) --login -i -c“
cd'$ {workspace_loc:/ $ {project_name}}'';
导出CC ='/ D / msys64 / mingw32 / bin / gcc.exe -DWIN32_LEAN_AND_MEAN -D_WIN32 -D_WIN64 = 0 -m32 -static -D_TIME_T_DEFINED -L / usr / lib';
-L / usr / lib
';
导出PATH =
:/ C / Perl64 / bin:
:/ d / msys64 / mingw32 / i686-w64-mingw32 / bin:
:/ d / msys64 / mingw32 / bin:
:/ usr / local / bin:
$ PATH;
echo PATH是:$ PATH;
./配置mingw不共享no-asm no-md2 --prefix = pwd --openssldir = pwd;
依靠
制作

然后构建完成。 注意:该路径优先于内置的MinGW64 Perl较新的Perl。