Crypto errors on link with MinGW/MSYS

729 views
Skip to first unread message

BryanD

unread,
Dec 12, 2010, 2:00:52 AM12/12/10
to SQLCipher Users
the configure command was: $ ./configure --disable-amalgamation --
disable-tcl CFLAGS="-DSQLITE_HAS_CODEC -I/c/OpenSSL/include" LDFLAGS="-
leay32 -L/c/OpenSSL/bin"

make reported "libtool: link: warning: undefined symbols not allowed
in i686-pc-mingw32 shared libraries"

make dll reported:

.libs/crypto.o:crypto.c:(.text+0x22): undefined reference to
`EVP_get_cipherbyname'
.libs/crypto.o:crypto.c:(.text+0x2b): undefined reference to
`OPENSSL_add_all_algorithms_noconf'
.libs/crypto.o:crypto.c:(.text+0x526): undefined reference to
`PKCS5_PBKDF2_HMAC_SHA1'
.libs/crypto.o:crypto.c:(.text+0x59d): undefined reference to
`RAND_pseudo_bytes'
.libs/crypto.o:crypto.c:(.text+0x5ef): undefined reference to
`EVP_CipherInit'
.libs/crypto.o:crypto.c:(.text+0x605): undefined reference to
`EVP_CIPHER_CTX_set_padding'
.libs/crypto.o:crypto.c:(.text+0x633): undefined reference to
`EVP_CipherInit'
.libs/crypto.o:crypto.c:(.text+0x660): undefined reference to
`EVP_CipherUpdate'
.libs/crypto.o:crypto.c:(.text+0x691): undefined reference to
`EVP_CipherFinal'
.libs/crypto.o:crypto.c:(.text+0x6a8): undefined reference to
`EVP_CIPHER_CTX_cleanup'
.libs/crypto.o:crypto.c:(.text+0x7ab): undefined reference to
`EVP_get_cipherbyname'
.libs/crypto.o:crypto.c:(.text+0x7bf): undefined reference to
`EVP_CIPHER_key_length'
.libs/crypto.o:crypto.c:(.text+0x7d3): undefined reference to
`EVP_CIPHER_iv_length'
.libs/crypto.o:crypto.c:(.text+0xca0): undefined reference to
`RAND_pseudo_bytes'
.libs/crypto.o:crypto.c:(.text+0xefa): undefined reference to
`RAND_pseudo_bytes'
collect2: ld returned 1 exit status
make: *** [sqlite3.dll] Error 1

Obviously, it can't find "libeay32.dll". However, the output of "ls -
R /c/OpenSSL" is

/c/OpenSSL:
bin include lib ssl

/c/OpenSSL/bin:
libeay32.dll openssl.exe ssleay32.dll

/c/OpenSSL/include:
openssl

/c/OpenSSL/include/openssl:
aes.h conf.h ecdsa.h obj_mac.h rc4.h ts.h
applink.c conf_api.h engine.h objects.h ripemd.h
txt_db.h
asn1.h crypto.h err.h ocsp.h rsa.h ui.h
asn1_mac.h des.h evp.h opensslconf.h safestack.h
ui_compat.h
asn1t.h des_old.h hmac.h opensslv.h seed.h
whrlpool.h
bio.h dh.h idea.h ossl_typ.h sha.h x509.h
blowfish.h dsa.h krb5_asn.h pem.h ssl.h
x509_vfy.h
bn.h dso.h kssl.h pem2.h ssl2.h
x509v3.h
buffer.h dtls1.h lhash.h pkcs12.h ssl23.h
camellia.h e_os2.h md4.h pkcs7.h ssl3.h
cast.h ebcdic.h md5.h pqueue.h stack.h
cms.h ec.h mdc2.h rand.h symhacks.h
comp.h ecdh.h modes.h rc2.h tls1.h

/c/OpenSSL/lib:
engines libeay32.lib ssleay32.lib

/c/OpenSSL/lib/engines:
4758cca.dll atalla.dll chil.dll gmp.dll nuron.dll
sureware.dll
aep.dll capi.dll cswift.dll gost.dll padlock.dll ubsec.dll

/c/OpenSSL/ssl:
openssl.cnf

What mistake did I make?

Stephen Lombardo

unread,
Dec 14, 2010, 2:47:56 PM12/14/10
to sqlc...@googlegroups.com
Hi Brian,

It looks like the Makefile may have changed in one of the upstream SQLite releases, and the LDFLAGS aren't included in the dll make target's build command. Thus, your linker options are not being passed to the command that builds the DLL.

For a quick fix, try to move your -l and -L options into CFLAGS instead. You'll get some noise from gcc saying that the linker inputs were ignored because linking wasn't done, but those are safe to ignore. Alternately, you can edit the Makefile generated by configure, locate the sqlite3.dll: target and append the requisite link options there. 

Let us know if that works out for you. 

Cheers,
Stephen

BryanD

unread,
Dec 16, 2010, 6:49:01 AM12/16/10
to SQLCipher Users
Your "quick fix" seems to have worked. "make" still gave the
"undefined symbols in DLLs" warning, but "make dll" had no errors or
warnings and both sqlite3.exe and sqlite3.dll exist.

Now, to find a fast way to test their functionality before I code the
actual app and find a problem in way too many lines of code.
Reply all
Reply to author
Forward
0 new messages