I trying to build sqlcipher on iOS/Mac OS, but can't succeed


#1

I used OpenSSL 1.0.2 from homebrew and build sqlcipher from sources. But when I tried to use it in qsqlcipher (https://github.com/sjemens/qsqlcipher-qt5/tree/android), I got an error:

“ld: warning: ld: warning: ignoring file /usr/local/lib/libsqlcipher.a, file was built for archive which is not the architecture being linked (x86_64): /usr/local/lib/libsqlcipher.a”.


#2

Hi @tr1cks

When linking static builds of OpenSSL for Android, they must be compiled using the Android NDK. This is what SQLCipher for Android does already.


#3

But I am trying to build for iOS/Mac OS. For Android binaries already provided in that repo.


#4

Hi @tr1cks

But I am trying to build for iOS/Mac OS.

It sounds like the architecture you may have installed does not match with the platform you are compiling for (e.g., i386 vs. x86_64). You might consider building the OpenSSL libraries yourself, then link those with your qsqlcipher-qt5 project.


#5

I built them, but nothing changes. May be gcc was used instead of clang and this is the root of the problem. Can you suggest how to force Clang usage for building OpenSSL and SQLCipher?

Also I get an error when try to run “make tests”:

gcc -DSQLITE_HAS_CODEC -I/opt/libs/openssl-1.1.1b-macos-x64/include/ -DSQLCIPHER_CRYPTO_OPENSSL -DSQLITE_OS_UNIX=1 -I. -o sessionfuzz ~/Projects/Cpp/sqlcipher/test/sessionfuzz.c -lz -lcrypto  
Undefined symbols for architecture x86_64:
  "_HMAC_CTX_free", referenced from:
      _sqlcipher_openssl_hmac in sessionfuzz-7bec5e.o
  "_HMAC_CTX_new", referenced from:
      _sqlcipher_openssl_hmac in sessionfuzz-7bec5e.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [sessionfuzz] Error 1

And how to specify cross compile of sqlcipher to iOS?