【问题标题】:undefined reference to `sqlite3_open'对“sqlite3_open”的未定义引用
【发布时间】:2015-01-21 06:12:26
【问题描述】:

我正在尝试遵循一些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

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

【问题讨论】:

标签: c++ linux sqlite


【解决方案1】:

我没有直接从 shell 编译的经验。 在 CodeBlocks 中,需要指出“sqlite3.h”头文件和“libsqlite3.so”dll 的路径。 如果链接器设置中没有指定 dll,就会出现上面提到的问题。

【讨论】:

    猜你喜欢
    • 2012-03-12
    • 2013-06-02
    • 2011-03-27
    • 2022-01-22
    • 2016-04-04
    • 2015-11-03
    • 2011-08-11
    • 2019-07-22
    • 2015-07-20
    相关资源
    最近更新 更多