1
我想在(64位)Windows 7上使用OpenSSL構建C文件。我已經從官方OpenSSL站點下載了最新的完整二進制文件,並且正在使用MinGW,並已將相應的bin
目錄添加到PATH
。但是我收到以下錯誤:OpenSSL ON WINDOWS !! - ld.exe找不到-lcrypto/-leay32
c:\Workspace\OSAccess\c>gcc -I%JAVA_HOME%\include -I%JAVA_HOME%\include\win32 -Ic:\OpenSSL-Win64\include -std=c99 -lm -lcrypto -o libosaccess.dll osaccess.c
c:/mingw/bin/../lib/gcc/mingw32/4.8.1/../../../../mingw32/bin/ld.exe: cannot find -lcrypto
collect2.exe: error: ld returned 1 exit status
我無法找到任何文件名爲libcrypto.dll
或cryptolib.dll
,所以我試圖從源代碼建立自己的OpenSSL,使用附帶的安裝說明,因爲我可以看到靜態庫對於crypto
和ssl
似乎不隨Windows安裝一起發貨。我在其他帖子中看到了其他一些庫的參考文獻,libeay32
和ssleay32
,但是這些庫返回相同的錯誤。
如果我刪除-lcrypto
(或其它),然後我得到Undefined reference
錯誤:
c:\Workspace\OSAccess\c>gcc -I%java_home%\include -I%java_home%\include\win32 -Ic:\OpenSSL-Win64\include -std=c99 -lm -o libosaccess.dll osaccess.c
C:\Users\xxxx\AppData\Local\Temp\ccbi3e1T.o:osaccess.c:(.text+0x383): undefined reference to '[email protected]'
C:\Users\xxxx\AppData\Local\Temp\ccbi3e1T.o:osaccess.c:(.text+0x3d1): undefined reference to '[email protected]'
C:\Users\xxxx\AppData\Local\Temp\ccbi3e1T.o:osaccess.c:(.text+0x445): undefined reference to '[email protected]'
C:\Users\xxxx\AppData\Local\Temp\ccbi3e1T.o:osaccess.c:(.text+0x73d): undefined reference to 'EVP_CIPHER_CTX_init'
C:\Users\xxxx\AppData\Local\Temp\ccbi3e1T.o:osaccess.c:(.text+0x742): undefined reference to 'EVP_aes_256_cbc'
C:\Users\xxxx\AppData\Local\Temp\ccbi3e1T.o:osaccess.c:(.text+0x76a): undefined reference to 'EVP_EncryptInit_ex'
C:\Users\xxxx\AppData\Local\Temp\ccbi3e1T.o:osaccess.c:(.text+0x794): undefined reference to 'EVP_EncryptUpdate'
C:\Users\xxxx\AppData\Local\Temp\ccbi3e1T.o:osaccess.c:(.text+0x7d2): undefined reference to 'EVP_EncryptFinal_ex'
C:\Users\xxxx\AppData\Local\Temp\ccbi3e1T.o:osaccess.c:(.text+0x81c): undefined reference to 'EVP_CIPHER_CTX_cleanup'
C:\Users\xxxx\AppData\Local\Temp\ccbi3e1T.o:osaccess.c:(.text+0x865): undefined reference to 'EVP_CIPHER_CTX_init'
C:\Users\xxxx\AppData\Local\Temp\ccbi3e1T.o:osaccess.c:(.text+0x86a): undefined reference to 'EVP_aes_256_cbc'
C:\Users\xxxx\AppData\Local\Temp\ccbi3e1T.o:osaccess.c:(.text+0x892): undefined reference to 'EVP_DecryptInit_ex'
C:\Users\xxxx\AppData\Local\Temp\ccbi3e1T.o:osaccess.c:(.text+0x8bc): undefined reference to 'EVP_DecryptUpdate'
C:\Users\xxxx\AppData\Local\Temp\ccbi3e1T.o:osaccess.c:(.text+0x8fa): undefined reference to 'EVP_DecryptFinal_ex'
C:\Users\xxxx\AppData\Local\Temp\ccbi3e1T.o:osaccess.c:(.text+0x930): undefined reference to 'EVP_CIPHER_CTX_cleanup'
有一看[無法找到的,libcrypto庫錯誤](http://stackoverflow.com/questions/10368671/cannot-find-libcrypto-library-error) –
添加'-Lc:\ OpenSSL-Win64 -leay32'就是解決這個問題的方法。 – MeanwhileInHell
...和'-Lc:\ Windows \ System32 -lnetapi32'爲Netbios錯誤 – MeanwhileInHell