C++ 如何将SQLite与c++;在Ubuntu上?(未定义的参考错误)

C++ 如何将SQLite与c++;在Ubuntu上?(未定义的参考错误),c++,ubuntu,sqlite,C++,Ubuntu,Sqlite,我想在Ubuntu上使用C++的SQLite。我选择从中尝试这个例子。但是当运行c++test.cpp-o test时,我得到了错误: /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+0x12

我想在Ubuntu上使用C++的SQLite。我选择从中尝试这个例子。但是当运行
c++test.cpp-o test时,我得到了错误:

/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

我认为问题和这里一样:。但是我没有make文件,也没有使用netbeans。

这是一个链接器错误,您没有链接到任何库。使用-llibname链接到正确的库,其中libname是从一开始就删除了lib的库的名称。例如,如果libname是libsqlite3.so,请尝试在编译步骤结束时添加
-lsqlite3
。当然,如果该库位于非标准位置,您还需要使用
-L/path/to/lib
选项提供该库的路径,显然您需要先安装相关库。

我不确定,但我认为sqlite的库是-libsqlite或-libsqlite3。是的,谢谢。这就是我上面链接的线程中的内容<代码>-lsqlite3
在命令的末尾完成了魔术。我在这里找到了答案:。