如何在 iOS 应用程序中使用 Berkeley DB?

发布于 2024-12-05 12:11:30 字数 136 浏览 0 评论 0原文

我想在 iOS 应用程序中使用 Berkeley DB,但我不知道如何去做。

如何将 Berkeley DB 集成到 iOS 项目中?你如何通过 Objective-C 与它通信?

是否有任何教程或示例可以演示如何做到这一点?

I would like to use the Berkeley DB within an iOS application, but I'm not sure how to go about this.

How do you integrate the Berkeley DB within an iOS project? How do you communicate with it via Objective-C?

Are there any tutorials or examples out there that might demonstrate how to do this?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

能否归途做我良人 2024-12-12 12:11:30

首先要注意的是,该库是 C++,而不是 Objective-C。这不是问题,因为 Objective-C 可以调用 C++。另外,教程中没有太多内容,但您需要自己完成以下内容:

下载

API

安装时您可能需要知道的所有内容是 此处

在 iOS 设备上构建它的具体部分是 此处

C++ 示例

从 Objective-C 调用 C++

The first thing to note is that the library is C++, not objective-c. This isn't an issue since objective-c can call C++. Also, there isn't much in the way of tutorials, but here is what you will need to do it yourself:

Download

API

Everything you probably need to know to install is here

The specific section on building it on an iOS device is here

C++ Examples

Calling C++ from Objective-C

三寸金莲 2024-12-12 12:11:30

我正在使用 XCode 版本 4.3.2 (4E2002) 和 Berkeley db-5.3.15。

在构建模拟器时我必须使用以下内容,因为官方文档似乎没有更新。

DEV_iOS=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer
export SDK_iOS=${DEV_iOS}/SDKs/iPhoneSimulator5.1.sdk
export COMPILER_iOS=${DEV_iOS}/usr/bin
export CC=${COMPILER_iOS}/gcc
export CXX=${COMPILER_iOS}/g++
export LDFLAGS="-arch i686 -pipe -Os -gdwarf-2 -no-cpp-precomp -mthumb -isysroot ${SDK_iOS}"
export CFLAGS=${LDFLAGS}
export CXXFLAGS=${LDFLAGS}
export LD=${COMPILER_iOS}/ld
export CPP=${COMPILER_iOS}/cpp
export AR=${COMPILER_iOS}/ar
export AS=${COMPILER_iOS}/as
export NM=${COMPILER_iOS}/nm
export CXXCPP=${COMPILER_iOS}/cpp
export RANLIB=${COMPILER_iOS}/ranlib

../dist/configure --host=i686-apple-darwin10 --with-cryptography=no --enable-shared=no --enable-sql --prefix=/build_output_dir

make install

并遵循该设备。

DEV_iOS=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer
export SDK_iOS=${DEV_iOS}/SDKs/iPhoneSimulator5.1.sdk
export COMPILER_iOS=${DEV_iOS}/usr/bin
export CC=${COMPILER_iOS}/gcc
export CXX=${COMPILER_iOS}/g++
export LDFLAGS="-arch armv6 -pipe -Os -gdwarf-2 -no-cpp-precomp -mthumb -isysroot ${SDK_iOS}"
export CFLAGS=${LDFLAGS}
export CXXFLAGS=${LDFLAGS}
export LD=${COMPILER_iOS}/ld
export CPP=${COMPILER_iOS}/cpp
export AR=${COMPILER_iOS}/ar
export AS=${COMPILER_iOS}/as
export NM=${COMPILER_iOS}/nm
export CXXCPP=${COMPILER_iOS}/cpp
export RANLIB=${COMPILER_iOS}/ranlib

../dist/configure --host=arm-apple-darwin10 --with-cryptography=no --enable-shared=no  --enable-sql --prefix=/build_output_dir

make install

我使用 lipo 命令来检查生成的库是否构建为所需的架构。

lipo -info libdb-5.3.a

在配置中指定“--enable-sql”会为您创建 SQL API,我使用的是与 SQLite3 相同的数据库包装器。

I'm using XCode Version 4.3.2 (4E2002) with Berkeley db-5.3.15.

I had to use following when building for Simulator because official doc doesn't seems to be updated.

DEV_iOS=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer
export SDK_iOS=${DEV_iOS}/SDKs/iPhoneSimulator5.1.sdk
export COMPILER_iOS=${DEV_iOS}/usr/bin
export CC=${COMPILER_iOS}/gcc
export CXX=${COMPILER_iOS}/g++
export LDFLAGS="-arch i686 -pipe -Os -gdwarf-2 -no-cpp-precomp -mthumb -isysroot ${SDK_iOS}"
export CFLAGS=${LDFLAGS}
export CXXFLAGS=${LDFLAGS}
export LD=${COMPILER_iOS}/ld
export CPP=${COMPILER_iOS}/cpp
export AR=${COMPILER_iOS}/ar
export AS=${COMPILER_iOS}/as
export NM=${COMPILER_iOS}/nm
export CXXCPP=${COMPILER_iOS}/cpp
export RANLIB=${COMPILER_iOS}/ranlib

../dist/configure --host=i686-apple-darwin10 --with-cryptography=no --enable-shared=no --enable-sql --prefix=/build_output_dir

make install

and following for the device.

DEV_iOS=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer
export SDK_iOS=${DEV_iOS}/SDKs/iPhoneSimulator5.1.sdk
export COMPILER_iOS=${DEV_iOS}/usr/bin
export CC=${COMPILER_iOS}/gcc
export CXX=${COMPILER_iOS}/g++
export LDFLAGS="-arch armv6 -pipe -Os -gdwarf-2 -no-cpp-precomp -mthumb -isysroot ${SDK_iOS}"
export CFLAGS=${LDFLAGS}
export CXXFLAGS=${LDFLAGS}
export LD=${COMPILER_iOS}/ld
export CPP=${COMPILER_iOS}/cpp
export AR=${COMPILER_iOS}/ar
export AS=${COMPILER_iOS}/as
export NM=${COMPILER_iOS}/nm
export CXXCPP=${COMPILER_iOS}/cpp
export RANLIB=${COMPILER_iOS}/ranlib

../dist/configure --host=arm-apple-darwin10 --with-cryptography=no --enable-shared=no  --enable-sql --prefix=/build_output_dir

make install

I used lipo command to check if resulting libraries build for desired architecture.

lipo -info libdb-5.3.a

Specifying "--enable-sql" at config creates the SQL API for you, I'm using same DB wrapper I used to have for SQLite3.

感情废物 2024-12-12 12:11:30

其他答案中没有提到的一件事是,如果您不想使用 Oracle 的开源许可证(这要求您提供源代码),则必须向 Oracle(版本 2+)付费。

One thing that isn’t mentioned in any of the other answers is that you have to pay Oracle (for version 2+) if you don't want to use their open source license (which requires you to make your source code available).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文