gcc -lssl -lcrypto -o test test.c -IC:\openssl\include-6ren">
gpt4 book ai didi

c - "cannot find -lcrypto -lssl"在带有 MinGW 的 Windows 上使用 OpenSSL

转载 作者:可可西里 更新时间:2023-11-01 10:34:28 30 4
gpt4 key购买 nike

尝试 openssl 的 c 代码,在命令提示符下编译时出现此错误。

c:\openssl>gcc -lssl -lcrypto -o test test.c -IC:\openssl\include\
c:/mingw/bin/../lib/gcc/mingw32/4.8.1/../../../../mingw32/bin/ld.exe: cannot find -lssl
c:/mingw/bin/../lib/gcc/mingw32/4.8.1/../../../../mingw32/bin/ld.exe: cannot find -lcrypto
collect2.exe: error: ld returned 1 exit status

现在我该怎么办,请帮忙

编辑:即使这些也无济于事:

c:\openssl>gcc -o test test.c  -lssl -lcrypto -Ic:\openssl\include\
c:\openssl>gcc -o test test.c -I c:\openssl\include\ -L c:\openssl\lib -lssl -lcrypto
c:\openssl>gcc -o test test.c -Lc:\openssl\lib -lssl -lcrypto -Ic:\openssl\include\

最佳答案

首先你需要用 mingw 编译 openssl,你链接到的二进制文件是用 Visual Studio 编译的,已经过时并且包含安全漏洞。

0.9.8 支持已停止,因此我建议使用 1.0.1+。

安装 ActivePerl 并删除 Stawberry Perl,因为它与 openssl 不兼容。

从以下位置下载最新的 1.0.1 源代码 (openssl-1.0.1q.tar.gz):https://openssl.org/source/

在您将 openssl 源解压缩到的目录中的 msys 控制台中运行以下命令:

 $ perl Configure mingw --prefix=/c/openssl
$ make depend
$ make
$ make install

然后运行你的编译命令:

gcc -o test test.c -Lc:\openssl\lib -lssl -lcrypto -Ic:\openssl\include\

编辑:mingw 在 0.9.8 上存在构建问题,因此请使用 1.0.1 或更高版本并使用 ActivePerl 而不是 Strawberry Perl。

关于c - "cannot find -lcrypto -lssl"在带有 MinGW 的 Windows 上使用 OpenSSL,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34752186/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com