“找不到-lcrypto -lssl";使用 MinGW 在 Windows 上使用 OpenSSL [英] "cannot find -lcrypto -lssl" with OpenSSL on Windows with MinGW

查看:147
本文介绍了“找不到-lcrypto -lssl";使用 MinGW 在 Windows 上使用 OpenSSL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

Trying out a c code for openssl, and this error showed up while compiling it in the command prompt.

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

现在我该怎么办,请帮忙.

now what should i do, please help.

即使这些也无济于事:

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 编译的,已经过时并且包含安全漏洞.

First off you need to compile openssl with mingw, the binaries you linked to were compiled with Visual Studio and are out of date and contain security vulnerabilites.

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

0.9.8 support is discontinued so I would advise using 1.0.1+.

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

Install ActivePerl and remove Stawberry Perl as it is not compatible with openssl.

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

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

Run the following in the msys console in the directory where you extracted the openssl source to:

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

然后运行你的编译命令:

and then run your compile command:

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

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

There are build problems on 0.9.8 with mingw so use 1.0.1 or higher and use ActivePerl not Strawberry Perl.

这篇关于“找不到-lcrypto -lssl";使用 MinGW 在 Windows 上使用 OpenSSL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆