【问题标题】:Fail to build sqlcipher with mingw使用 mingw 构建 sqlcipher 失败
【发布时间】:2013-08-12 01:15:26
【问题描述】:

我在将 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"

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

【问题讨论】:

    标签: linker openssl mingw sqlcipher


    【解决方案1】:

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

    【讨论】:

    • 还有一些错误,日志显示:configure:10687: gcc -o conftest.exe -DSQLITE_HAS_CODEC -DSQLCIPHER_CRYPTO_OPENSSL -L/ssl/lib -lgdi32 -lssl -lcrypto conftest.c -lcrypto -lpthread >&5 c:/ssl/lib/libcrypto.a(rand_win.o):rand_win.c:(.text+0xa0c): undefined reference to CreateDCA@16' c:/ssl/lib/libcrypto.a(rand_win.o):rand_win.c:(.text+0xa19):对CreateCompatibleDC@4'的未定义引用
    【解决方案2】:

    配置: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)。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-08-29
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多