我是这样做的:
1)从MySQL下载Connector/C的源码版本
2)下载cmake(如果安装了macports,请输入“sudo port install cmake”)
3)从http://sites.google.com/site/michaelsafyan/coding/resources/how-to-guides/cross-compile-for-the-iphone/how-to-cross-compile-for-获取工具链文件the-iphone-使用-cmake
4) 在模拟器的工具链文件中,从包含 CMAKE_OSX_ARCHITECTURES 的行中删除一种架构
5) 如果要构建模拟器,请复制 /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator3.2.sdk/usr/include/netinet/ 中缺少的标头(ip.h 和 in_system.h)来自 /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS3.2.sdk/usr/include/netinet
6) 在某处创建一个名为“compiled_library”的目录,例如在桌面上
7)像这样调用cmake: cmake -DCMAKE_TOOLCHAIN_FILE=/path/to/iphone-toolchain-file -DCMAKE_INSTALL_PREFIX=/path/to/compiled_library -DHAVE_FDATASYNC:INTERNAL=0
8) 请注意,如果您想第二次运行 cmake,您可能必须先删除缓存文件
9) 输入 make install
10) 现在 /path/to/compiled_library 中已编译库。通过“添加现有文件...”将头文件目录和 libmysql.a 复制到您的 xcode 项目中。该库应自动添加到链接器阶段。
11)哇哦。使用 mysql C API。
12) 如果这工作量太大,我目前正在为 iPhone 编写一个 MySQL 包装框架。我将在未来十年的某个时候发布它,并在此处放置一个链接。
编辑:其他人为 MySQL 客户端库创建了 Objective C 包装器:http://www.karlkraft.com/index.php/2010/09/17/mysql-for-iphone-and-osx/
| 归档时间: |
|
| 查看次数: |
4159 次 |
| 最近记录: |