Skip to content

Instantly share code, notes, and snippets.

@weiofcn
Last active December 19, 2017 09:16
Show Gist options
  • Save weiofcn/2dd3ed675853340f997c3f173c5bbe5f to your computer and use it in GitHub Desktop.
Save weiofcn/2dd3ed675853340f997c3f173c5bbe5f to your computer and use it in GitHub Desktop.
如何编译在iOS上可以使用的mongo-c-driver

下载openssl

https://github.com/x2on/OpenSSL-for-iPhone

下载mongodb-c-driver

http://mongoc.org/#download

编译mongodb-c-driver

./configure --disable-automatic-init-and-cleanup CC="/Applications/Xcode7.3.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang" LDFLAGS="-L/Users/XXX/OpenSSL-for-iPhone/lib" CPPFLAGS="-I/Users/XXX/OpenSSL-for-iPhone/include" CFLAGS="-isysroot /Applications/Xcode7.3.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS9.3.sdk -arch arm64" --enable-static --with-zlib=bundled --with-libbson=bundled --host=armv7-apple-darwin --enable-ssl=openssl

注意

  • LDFLAGS指定openssl库的路径
  • CPPFLAGS指定openssl头文件的路径
  • CC指定clang的位置
  • CFLAGS指定iOS的编译器参数

最后

  • libmongoc.alibbson.a和他们的头文件加入到工程,数量很多,建议在PC系统中make install以后拷贝头文件。
  • 需要替换bson的头文件引用尖括号为引号,数量很多,建议用替换的方式一次性决解。
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment