1

我在将 OpenSSL 链接到 SqlCipher 时遇到问题,在编译一个简单的 OpenSSL 演示时,看起来每件事都设置正确:

gcc  -Wall -o ssl-demo testssl.c -lssl -lcrypto -lwsock32 -lgdi32

但是当涉及到 sqlcipher 时,我收到以下消息:

configure: Release set to 3.7.17
configure: Version number set to 3007017
checking whether to support threadsafe operation... yes
checking for library containing pthread_create... -lpthread
checking for crypto library to use... openssl
checking for HMAC_Init_ex in -lcrypto... no
configure: error: Library crypto not found. Install openssl!"

在看configure.log

configure:10593: checking for crypto library to use
configure:10660: result: openssl
configure:10662: checking for HMAC_Init_ex in -lcrypto
configure:10687: gcc -o conftest.exe -DSQLITE_HAS_CODEC -DSQLCIPHER_CRYPTO_OPENSSL  -lgdi32 -lssl -lcrypto conftest.c -lcrypto  -lpthread  >&5
k:/qt/qt4.8.3/mingw/bin/../lib/gcc/mingw32/4.4.0/../../../libcrypto.a(rand_win.o):rand_win.c:(.text+0xa0c): undefined reference to `CreateDCA@16'
k:/qt/qt4.8.3/mingw/bin/../lib/gcc/mingw32/4.4.0/../../../libcrypto.a(rand_win.o):rand_win.c:(.text+0xa19): undefined reference to `CreateCompatibleDC@4'
k:/qt/qt4.8.3/mingw/bin/../lib/gcc/mingw32/4.4.0/../../../libcrypto.a(rand_win.o):rand_win.c:(.text+0xa2a): undefined reference to `GetDeviceCaps@8'
k:/qt/qt4.8.3/mingw/bin/../lib/gcc/mingw32/4.4.0/../../../libcrypto.a(rand_win.o):rand_win.c:(.text+0xa3a): undefined reference to `GetDeviceCaps@8'
k:/qt/qt4.8.3/mingw/bin/../lib/gcc/mingw32/4.4.0/../../../libcrypto.a(rand_win.o):rand_win.c:(.text+0xa50): undefined reference to `CreateCompatibleBitmap@12'
k:/qt/qt4.8.3/mingw/bin/../lib/gcc/mingw32/4.4.0/../../../libcrypto.a(rand_win.o):rand_win.c:(.text+0xa5e): undefined reference to `SelectObject@8'
k:/qt/qt4.8.3/mingw/bin/../lib/gcc/mingw32/4.4.0/../../../libcrypto.a(rand_win.o):rand_win.c:(.text+0xa70): undefined reference to `GetObjectA@12'
k:/qt/qt4.8.3/mingw/bin/../lib/gcc/mingw32/4.4.0/../../../libcrypto.a(rand_win.o):rand_win.c:(.text+0xae1): undefined reference to `BitBlt@36'
k:/qt/qt4.8.3/mingw/bin/../lib/gcc/mingw32/4.4.0/../../../libcrypto.a(rand_win.o):rand_win.c:(.text+0xaeb): undefined reference to `GetBitmapBits@12'
k:/qt/qt4.8.3/mingw/bin/../lib/gcc/mingw32/4.4.0/../../../libcrypto.a(rand_win.o):rand_win.c:(.text+0xb42): undefined reference to `SelectObject@8'
k:/qt/qt4.8.3/mingw/bin/../lib/gcc/mingw32/4.4.0/../../../libcrypto.a(rand_win.o):rand_win.c:(.text+0xb49): undefined reference to `DeleteObject@4'
k:/qt/qt4.8.3/mingw/bin/../lib/gcc/mingw32/4.4.0/../../../libcrypto.a(rand_win.o):rand_win.c:(.text+0xb53): undefined reference to `DeleteDC@4'
k:/qt/qt4.8.3/mingw/bin/../lib/gcc/mingw32/4.4.0/../../../libcrypto.a(rand_win.o):rand_win.c:(.text+0xb5d): undefined reference to `DeleteDC@4'
collect2: ld returned 1 exit status
configure:10687: $? = 1
configure: failed program was:
| /* confdefs.h */
| #define PACKAGE_NAME "sqlcipher"
| #define PACKAGE_TARNAME "sqlcipher"
| #define PACKAGE_VERSION "3.7.17"
| #define PACKAGE_STRING "sqlcipher 3.7.17"
| #define PACKAGE_BUGREPORT ""
| #define PACKAGE_URL ""
| /* end confdefs.h.  */
| #ifdef __cplusplus
| extern "C"
| #endif
| char HMAC_Init_ex ();
| int
| main ()
| {
| return HMAC_Init_ex ();
|   ;
|   return 0;
| }
configure:10696: result: no
configure:10706: error: Library crypto not found. Install openssl!"

用于编译 SqlCipher 的命令:

$ ./configure --enable-static=no --enable-tempstore=yes CFLAGS="-DSQLITE_HAS_CODEC" LDFLAGS="-lgdi32 -lssl -lcrypto"

我还尝试更改链接顺序,但这没有帮助。

4

2 回答 2

0

似乎 configure 无法找到您的 libcrypto 版本。您可以尝试调整LDFLAGSin 配置以包含-L/some/path/to/your/library.

于 2013-08-12T18:39:13.913 回答
0

配置:10687:gcc -o conftest.exe -DSQLITE_HAS_CODEC -DSQLCIPHER_CRYPTO_OPENSSL -lgdi32 -lssl -lcrypto conftest.c -lcrypto -lpthread >&5

如您所见-lgdi32,在第二个之前进行-lcrypto,并且需要在之后进行。要强制执行此操作,您必须添加LIBS="-lgdi32"到您的配置中。

如果您想深入了解它,请参阅./configure第 10668 行(版本 3.7.17)。

于 2013-09-07T02:25:03.637 回答