2012-06-21 74 views
1

iphone sqlite的未定義符號錯誤

http://www.techotopia.com/index.php/An_Example_SQLite_based_iPhone_Application

我創建了一個單一視圖的應用程序,並從本教程複製的代碼到viewcontroller.h和.m文件。在教程的每個部分之後,我編譯了代碼以確保它仍然可以正常工作。我在「創建數據庫和表」部分複製後首先出現錯誤。我收到以下錯誤。

Undefined symbols for architecture i386: 
    "_sqlite3_open", referenced from: 
     -[ViewController viewDidLoad] in ViewController.o 
    "_sqlite3_exec", referenced from: 
     -[ViewController viewDidLoad] in ViewController.o 
    "_sqlite3_close", referenced from: 
     -[ViewController viewDidLoad] in ViewController.o 
ld: symbol(s) not found for architecture i386 
clang: error: linker command failed with exit code 1 (use -v to see invocation) 

我搜索了無數的論壇,並嘗試了無數的東西。我導入了libsqlite3.dylib和libsqlite3.0.dylib。我正在使用xcode 4.2。它似乎與sqlite框架有關,但我不知道如何解決它。

任何幫助,您可以提供將不勝感激。

感謝,

伊恩

+0

是否進口「/usr/include/sqlite3.h」?它可能不在相同的路徑,但你可能需要這個頭。 –

回答

4

你可能需要添加庫/框架的源碼。使用這個參考併爲sqlite添加條目。也許你並沒有把它們添加到您的當前目標?:

add frameworks

+0

我覺得很愚蠢。我有測試目標中包含的libsqlite.dylib而不是主目標。非常感謝。 – iroosma

+0

發生在我們所有人身上。很高興你的問題解決了。 –