在32位平台上编译OpenSSL 1.1.1g失败(MSYS2)。

3

我正在尝试构建 OpenSSL 1.1.1g 版本。

我已经尝试使用 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

"perl Configure mingw shared no-hw no-asm no-md2 --prefix=pwd --openssldir=pwd "这是什么意思?Configure是什么?" - Håkon Hægland
你尝试过安装预编译的 OpenSSL 吗?使用命令 pacman -S openssl - Håkon Hægland
我需要构建它,以便在另一个已构建的产品中使用其库。因此,通过pacman安装是没有帮助的。 - anonCoder
错误:在“typedef”之前预期“;”:__MINGW_EXTENSION typedef __int64 _time64_t; :似乎宏“__MINGW_EXTENSION”未定义。在我的MSYS2终端中,我已经在包含文件“/usr/include/w32api/_mingw.h”中定义了它。你有这个包含文件吗? - Håkon Hægland
感谢您的回复。 @HåkonHægland:我确实有那个包含文件。 我打开了一个mingw32 MSys会话进行检查: /usr/include,但在那里不存在。如果您想让我尝试任何事情,我很乐意这样做。该文件驻留在: /mingw32/i686-w64-mingw32/include 将添加并重试。 - anonCoder
我添加了-include: export CPPFLAGS='-include /mingw32/i686-w64-mingw32/include/_mingw.h'; \这导致更多的错误,除非有要求,否则我不打算在此处包含它们。 - anonCoder
1个回答

1
一种解决方案是不要在MSys2下构建,而选择MinGW64。然后...
\mingw64\mingw32\msys\1.0\bin\bash.exe

然后...

(1) --login -i -c "
cd '${workspace_loc:/${project_name}}';
export 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
';
export PATH=
:/C/Perl64/bin:
:/d/msys64/mingw32/i686-w64-mingw32/bin:
:/d/msys64/mingw32/bin:
:/usr/local/bin:
$PATH;
echo PATH is: $PATH;
./Configure mingw no-shared no-asm no-md2 --prefix=pwd --openssldir=pwd;
make depend;
make
"

然后构建完成。 注意:这是为了使用比内置的MinGW64 Perl更新的Perl路径前缀。


只是一个警告 - 上面可能没有设置最佳标志。 - anonCoder

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接