我想从一些依赖OpenSSL的C代码中创建一个DLL库。我注意到,使用Anaconda可以安装OpenSSL,它还可以创建.h
和libeay32.lib
和libeay32.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
?