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

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

ご覧のとおり-lgdi32、秒の前-lcryptoに移動し、後に移動する必要があります。これを強制するLIBS="-lgdi32"には、構成に追加する必要があります。

詳しく知りたい場合は、./configure10668 行 (バージョン 3.7.17) を参照してください。

于 2013-09-07T02:25:03.637 に答える
0

configure が libcrypto のバージョンを特定できないようです。LDFLAGSを含めるように構成を調整してみてください-L/some/path/to/your/library

于 2013-08-12T18:39:13.913 に答える