如何在Ubuntu上使用带有c++的SQLite?(未定义的引用错误)
How to use SQLite with c++ on Ubuntu? (undefined reference error)
我想在Ubuntu上使用带有c++的SQLite。我选择从https://www.sqlite.org/quickstart.html.但当运行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
我认为问题与这里相同:Sqlite未定义引用`sqlite3_open';Ubuntu上的Netbeans C++中的错误,将SQLite集成到Netbeans C++Ubuntu中。但我没有make文件,也不使用netbeans。
这是一个链接器错误,您没有链接到任何库。使用-libname链接到正确的库,其中libname是从一开始就删除了lib的库的名称。例如,如果libname是libsqlite3,那么请尝试在编译步骤结束时添加-lsqlite3
。当然,如果该库位于使用-L/path/to/lib
选项的非标准位置,您还需要提供该库的路径,而且显然您需要先安装相关库。
相关文章:
- 编译C++时未定义的引用
- vscode g++链路故障:体系结构x86_64的未定义符号
- 如何修复此错误:未定义对"距离(浮点数,浮点数,浮点数,浮点数,浮点数)"的引用
- 我的项目不会像"undefined reference to `grpc::g_core_codegen_interface'"那样使用未定义的引用错误进行编译
- 不知道某个东西是否被忽略会引入未定义的行为吗
- 对C宏的未定义引用,但在定义它时会出现重新定义错误
- 未定义的引用在哪里
- 编译时的 CImg 库返回对"__imp_SetDIBitsToDevice"的未定义引用
- 对Py_Initialize()的未定义引用
- c++11评估顺序(未定义的行为)
- 使用mysql c++连接器的未定义引用
- 从python调用openMP共享库时,未定义opnMP函数
- 在 Mac 上使用 CMAKE 将 FFTW 和 FFTWPP 链接到项目中时未定义的符号
- Cmake 链接问题:未定义对 Button::mousePressEvent(QGraphicsSceneMouseE
- 未定义的引用 .. 使用 OpenCV 编译 C++ 代码时,从命令行
- 具有外部"c"和程序集的未定义函数
- 此增量后语句是否会导致未定义的行为?
- 尝试调用 .h 文件中定义的变量时出现变量未定义错误
- 如何在Ubuntu上使用带有c++的SQLite?(未定义的引用错误)
- sqlite c++体系结构x86_64的未定义符号