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

**URL:** <https://discuss.zetetic.net/t/i-trying-to-build-sqlcipher-on-ios-mac-os-but-cant-succeed/3485>\
**Category:** SQLCipher\
**Created:** [March 11, 2019, 1:25pm UTC](https://discuss.zetetic.net/t/i-trying-to-build-sqlcipher-on-ios-mac-os-but-cant-succeed/3485 "2019-03-11T13:25:02Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![tr1cks](https://avatars.discourse-cdn.com/v4/letter/t/eb8c5e/32.png) [@tr1cks](https://discuss.zetetic.net/u/tr1cks)\
**Post date:** [March 11, 2019, 1:25pm UTC](https://discuss.zetetic.net/t/i-trying-to-build-sqlcipher-on-ios-mac-os-but-cant-succeed/3485/1 "2019-03-11T13:25:02Z")

</div>

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](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”.

---

<div class="post-metadata">

**Author:** ![developernotes](https://sea2.discourse-cdn.com/flex016/user_avatar/discuss.zetetic.net/developernotes/32/1309_2.png) [@developernotes](https://discuss.zetetic.net/u/developernotes)\
**Post date:** [March 11, 2019, 1:40pm UTC](https://discuss.zetetic.net/t/i-trying-to-build-sqlcipher-on-ios-mac-os-but-cant-succeed/3485/2 "2019-03-11T13:40:39Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![tr1cks](https://avatars.discourse-cdn.com/v4/letter/t/eb8c5e/32.png) [@tr1cks](https://discuss.zetetic.net/u/tr1cks)\
**Post date:** [March 11, 2019, 1:42pm UTC](https://discuss.zetetic.net/t/i-trying-to-build-sqlcipher-on-ios-mac-os-but-cant-succeed/3485/3 "2019-03-11T13:42:44Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![developernotes](https://sea2.discourse-cdn.com/flex016/user_avatar/discuss.zetetic.net/developernotes/32/1309_2.png) [@developernotes](https://discuss.zetetic.net/u/developernotes)\
**Post date:** [March 11, 2019, 2:00pm UTC](https://discuss.zetetic.net/t/i-trying-to-build-sqlcipher-on-ios-mac-os-but-cant-succeed/3485/4 "2019-03-11T14:00:06Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![tr1cks](https://avatars.discourse-cdn.com/v4/letter/t/eb8c5e/32.png) [@tr1cks](https://discuss.zetetic.net/u/tr1cks)\
**Post date:** [March 12, 2019, 2:13pm UTC](https://discuss.zetetic.net/t/i-trying-to-build-sqlcipher-on-ios-mac-os-but-cant-succeed/3485/5 "2019-03-12T14:13:54Z")

</div>

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?
