如何在 XCode 4 的 i386 应用程序的 dylib 中使用 Sqlite?这种方法在 iPhone 应用程序中确实有效
在 XCode 4 For iOS 的 i386 应用程序的 dylib 中使用 Sqlite
我需要从目录添加一个名为 libsqlite3.0.dylib 的文件: /Developer/Platforms/iPhoneOS.platform/DeviceSupport/4.2.1 (8C148)/Symbols/usr/lib/
我有一种从 sqlite DB 列获取 MaxID 的方法。 这在我制作的通用 iOS 应用程序中运行良好。我想移植这段代码 转到 Mac 应用程序 i386。
因为我找不到 i386 这样的 dylib,所以我使用 下载文件:sqlite-autoconf-3070500.tar.gz
按照指示我在 /usr/local/lib
libsqlite3.a 中生成了 3 个文件 libsqlite3.la libsqlite3.dylib
在 XCode 中我已将 '/usr/local/lib' 添加到 构建设置->搜索路径->
我使用的库搜索路径: 导出 DYLD_LIBRARY_PATH=/usr/local/bin/:$DYLD_LIBRARY_PATH
当我取消注释时,出现以下构建错误 中的 sqlite 代码
AppDelegate.m Ld /Users/appleuser/Library/Developer/Xcode/DerivedData/iHungryMacNonDoc-dakfnxxiwzxehygtwrboebgysgwc/Build/Products/Debug/iHungryMacNonDoc.app/Contents/MacOS/iHungryMacNonDoc 正常 i386 cd /Users/appleuser/Cocoa/iHungryMacNonDoc setenv MACOSX_DEPLOYMENT_TARGET 10.6 /Developer/usr/bin/llvm-gcc-4.2 -arch i386 -isysroot /Developer/SDKs/MacOSX10.6.sdk -L/Users/appleuser/Library/Developer/Xcode/DerivedData/iHungryMacNonDoc-dakfnxxiwzxehygtwrboebgysgwc/Build/Products/调试 -L/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator4.3.sdk/usr/lib -L/Users/appleuser/Cocoa/iHungryMacNonDoc/../SqliteLib -L/Developer/Platforms/iPhoneSimulator.platform /Developer/SDKs/iPhoneSimulator4.3.sdk/usr/lib -F/Users/appleuser/Library/Developer/Xcode/DerivedData/iHungryMacNonDoc-dakfnxxiwzxehygtwrboebgysgwc/Build/Products/Debug -filelist /Users/appleuser/Library/Developer/Xcode /DerivedData/iHungryMacNonDoc-dakfnxxiwzxehygtwrboebgysgwc/Build/Intermediates/iHungryMacNonDoc.build/Debug/iHungryMacNonDoc.build/Objects-normal/i386/iHungryMacNonDoc.LinkFileList -mmacosx-version-min=10.6 -framework Cocoa -lsqlite3.0.8.6 -o / Users/appleuser/Library/Developer/Xcode/DerivedData/iHungryMacNonDoc-dakfnxxiwzxehygtwrboebgysgwc/Build/Products/Debug/iHungryMacNonDoc.app/Contents/MacOS/iHungryMacNonDoc
ld:找不到文件:/usr/lib/system/libdispatch_sim.dylib 用于架构 i386 Collect2: ld 返回 1 退出状态 命令 /Developer/usr/bin/llvm-gcc-4.2 失败,退出代码 1
AppDelegate.h 开始 ////////////
导入“AppDelegate.h”
导入“IngredXML.h”
导入“XmlListReader.h”
导入“Constants.h”
导入
导入
导入“/usr/include/sqlite3.h”
谢谢读完这篇文章就这么多了。请指教。 标记
Using Sqlite in a dylib in an i386 app in XCode 4
For iOS I needed to add a file namely libsqlite3.0.dylib from directory:
/Developer/Platforms/iPhoneOS.platform/DeviceSupport/4.2.1 (8C148)/Symbols/usr/lib/
I have a method that obtains and MaxID from a column of an sqlite DB.
This works fine in a universal iOS app I made. I want to port this code
over to a Mac app i386.
Because I could not find such an dylib for i386, I created one using
the download file: sqlite-autoconf-3070500.tar.gz
Following directions I produced 3 files in /usr/local/lib
libsqlite3.a
libsqlite3.la
libsqlite3.dylib
In XCode I have add '/usr/local/lib' to the
Build Setting->Search Paths->Library Search Paths
I have used:
export DYLD_LIBRARY_PATH=/usr/local/bin/:$DYLD_LIBRARY_PATH
I get the following build error when I uncomment the
sqlite code in AppDelegate.m
Ld /Users/appleuser/Library/Developer/Xcode/DerivedData/iHungryMacNonDoc-dakfnxxiwzxehygtwrboebgysgwc/Build/Products/Debug/iHungryMacNonDoc.app/Contents/MacOS/iHungryMacNonDoc normal i386
cd /Users/appleuser/Cocoa/iHungryMacNonDoc
setenv MACOSX_DEPLOYMENT_TARGET 10.6
/Developer/usr/bin/llvm-gcc-4.2 -arch i386 -isysroot /Developer/SDKs/MacOSX10.6.sdk -L/Users/appleuser/Library/Developer/Xcode/DerivedData/iHungryMacNonDoc-dakfnxxiwzxehygtwrboebgysgwc/Build/Products/Debug -L/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator4.3.sdk/usr/lib -L/Users/appleuser/Cocoa/iHungryMacNonDoc/../SqliteLib -L/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator4.3.sdk/usr/lib -F/Users/appleuser/Library/Developer/Xcode/DerivedData/iHungryMacNonDoc-dakfnxxiwzxehygtwrboebgysgwc/Build/Products/Debug -filelist /Users/appleuser/Library/Developer/Xcode/DerivedData/iHungryMacNonDoc-dakfnxxiwzxehygtwrboebgysgwc/Build/Intermediates/iHungryMacNonDoc.build/Debug/iHungryMacNonDoc.build/Objects-normal/i386/iHungryMacNonDoc.LinkFileList -mmacosx-version-min=10.6 -framework Cocoa -lsqlite3.0.8.6 -o /Users/appleuser/Library/Developer/Xcode/DerivedData/iHungryMacNonDoc-dakfnxxiwzxehygtwrboebgysgwc/Build/Products/Debug/iHungryMacNonDoc.app/Contents/MacOS/iHungryMacNonDoc
ld: file not found: /usr/lib/system/libdispatch_sim.dylib for architecture i386
collect2: ld returned 1 exit status
Command /Developer/usr/bin/llvm-gcc-4.2 failed with exit code 1
AppDelegate.h begins
////////////
import "AppDelegate.h"
import "IngredXML.h"
import "XmlListReader.h"
import "Constants.h"
import
import
import "/usr/include/sqlite3.h"
Thanks so much for reading this. Please advise.
Mark
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我将链接到 SDK 中附带的 SQLite dylib,该库位于
/Developer/SDKs/MacOSX10.6.sdk/usr/lib/libsqlite3.dylib
(根据需要替换您的目标 SDK)。I'd link against the SQLite dylib shipped in the SDK, which is at
/Developer/SDKs/MacOSX10.6.sdk/usr/lib/libsqlite3.dylib
(substitute your target SDK as needed).