对"sqlite3_open"的未定义引用

undefined reference to `sqlite3_open'

本文关键字:未定义 引用 sqlite3 open      更新时间:2023-10-16

我正在尝试遵循一些sqlite C++教程,以便能够从Linux上的C++代码中访问数据库。 sqlite3已安装并正常工作,但是当我尝试编译链接(创建表)上给出的示例代码时,出现以下错误:

 g++  build/test.o -o bin/test -pthread -L lib 
build/test.o: In function `main':
/home/alexander/Projects/Test/src/test.cpp:22: undefined reference to `sqlite3_open'
/home/alexander/Projects/Test/src/test.cpp:24: undefined reference to `sqlite3_errmsg'
/home/alexander/Projects/Test/src/test.cpp:39: undefined reference to `sqlite3_exec'
/home/alexander/Projects/Test/src/test.cpp:42: undefined reference to `sqlite3_free'
/home/alexander/Projects/Test/src/test.cpp:46: undefined reference to `sqlite3_close'
collect2: error: ld returned 1 exit status

我需要安装其他东西吗?还是我需要设置一些路径?

我没有直接从shell编译的练习。在 CodeBlock 中,有必要指向 "sqlite3.h" 标头和 "libsqlite3.so" dll 的路径。如果未在链接器设置中指定 dll,则会出现上述问题。