如何在Windows中链接openssl`libeay32.dll`

时间:2019-02-04 15:54:37

标签: c openssl linker mingw

我想从一些依赖OpenSSL的C代码中创建一个DLL库。我注意到,使用Anaconda可以安装OpenSSL,它还可以创建.hlibeay32.liblibeay32.dll文件。

要创建DLL,我正在使用MinGW,并且正在运行以下命令:

gcc -std=c11 -fPIC -c -g -O2 -I "D:\Users\david\AppData\Local\Continuum\anaconda2\envs\py3\Library\include" file.h file.c -L "D:/Users/david/AppData/Local/Continuum/anaconda2/envs/py3/Library/lib" -Wl,--whole-archive -llibeay32 -Wl,--no-whole-archive

然后,当我跑步时

gcc -shared file.o -o libVRF.dll -L "D:/Users/david/AppData/Local/Continuum/anaconda2/envs/py3/Library/lib" -L "D:\Users\david\AppData\Local\Continuum\anaconda2\envs\py3\Library\bin" -Wl,--whole-archive -llibeay32 -Wl,--no-whole-archive

我知道

c:/mingw/bin/../lib/gcc/mingw32/8.2.0/../../../../mingw32/bin/ld.exe: D:/Users/david/AppData/Local/Continuum/anaconda2/envs/py3/Library/lib/libeay32.lib: member D:/Users/david/AppData/Local/Continuum/anaconda2/envs/py3/Library/lib/libeay32.lib(LIBEAY32.dll) in archive is not an object collect2.exe: error: ld returned 1 exit status

为什么会这样?

我还注意到我有一个文件夹C:\Program Files (x86)\Intel\iCLS Client,其中有许多.dll,其中包括libeay32.dll。我尝试稍作更改即可运行上述命令

gcc -shared file.o -o libVRF.dll -L "C:\Program Files (x86)\Intel\iCLS Client" -Wl,--whole-archive -llibeay32 -Wl,--no-whole-archive

,我遇到了类似undefined reference to 'EVP_MD_CTX_new'的错误。我认为发生这种情况是因为我的C代码使用的是旧版本的openSSL,而这个libeay32.dll可能是较新的。

如何使Anaconda libeay32.dll工作?还是我该如何工作libeay32.dll

0 个答案:

没有答案