title: Dynamically linking SQLCipher on OS X with C++
body: <p>I originally wanted to compile SQLCipher statically since it seems like it is easier to link up, but I have been unsuccessful at that. The only place I can find that discusses compiling SQLCipher on OS X is <a href="http://vinceyuan.blogspot.tw/2013/07/build-sqlcipher-on-mac-os-x.html" rel="nofollow">this blog post</a>, but even he was not able to get the static compiling to work. </p>
  
  <p>I was able to get the dynamic compiling working for the SQLCipher and I am able to use the sqlcipher command line program as mentioned in the blog, but now I want to use sqlcipher in a compiled C++ program. I have never dealt directly with dynamic compiling in the command line so I am a bit lost.</p>
  
  <p>It looks like it produces a libtool file libsqlcipher.la so I am wondering how I should import it in C++ <code>#include "libsqlcipher.h"</code>? Looking around at tutorials for libtool they mostly mention how to compile it but I have not found any simple examples of how to link it. </p>
  
  <p>I attempted something like this based on what I saw but I got a couple of errors: </p>
  
  <pre><code>libtool g++ -o test EncryptDatabases.cpp sqlcipher/libsqlcipher.la
  error: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/libtool: can't open file: g++ (No such file or directory)
  error: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/libtool: file: EncryptDatabases.cpp is not an object file (not allowed in a library)
  error: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/libtool: file: sqlcipher/libsqlcipher.la is not an object file (not allowed in a library)
  </code></pre>