我想在Ubuntu上使用SQLite和C++。我選擇嘗試https://www.sqlite.org/quickstart.html的示例。但運行c++ test.cpp -o test
,當我得到的錯誤:如何在Ubuntu上使用SQLite與c + +? (未定義參考錯誤)
/tmp/ccTwwjKw.o: In function `main':
test.cpp:(.text+0xf1): undefined reference to `sqlite3_open'
test.cpp:(.text+0x106): undefined reference to `sqlite3_errmsg'
test.cpp:(.text+0x12e): undefined reference to `sqlite3_close'
test.cpp:(.text+0x15d): undefined reference to `sqlite3_exec'
test.cpp:(.text+0x18f): undefined reference to `sqlite3_free'
test.cpp:(.text+0x19b): undefined reference to `sqlite3_close'
collect2: ld gab 1 als Ende-Status zurück
我認爲這個問題是因爲這裏是相同的:Sqlite undefined reference to `sqlite3_open' error in Netbeans C++ on Ubuntu, Integrating SQLite into Netbeans C++ Ubuntu。但是我沒有makefile,也沒有使用netbeans。
我在這裏找到了答案:http://stackoverflow.com/questions/9090639。 – pirad 2012-07-18 12:42:23