【发布时间】:2017-04-14 01:16:39
【问题描述】:
我正在尝试在 Windows 上将 SQLite 与 c++ 一起使用。我的代码是这样的
#include <stdio.h>
#include <sqlite3.h>
int main(int argc, char* argv[])
{
sqlite3 *db;
char *zErrMsg = 0;
int rc;
rc = sqlite3_open("test.db", &db);
if( rc ){
fprintf(stderr, "Can't open database: %s\n", sqlite3_errmsg(db));
return(0);
}else{
fprintf(stderr, "Opened database successfully\n");
}
sqlite3_close(db);
}
返回错误信息
C:\sqlite: No such file or directory
compilation terminated.
还有其他几个关于此的 stackoverflow 问题,但它们都通过将 #include <sqlite3.h> 更改为 #include "sqlite3.h" 或 #include <full_path_to_sqlite3> 来解决,但都不起作用
编译时包含-lsqlite3也解决了一个问题,但这会返回
c:/mingw/bin/../lib/gcc/mingw32/5.3.0/../../../../mingw32/bin/ld.exe: cannot find -lsqlite3
collect2.exe: error: ld returned 1 exit status
这对我来说很奇怪,因为 sqlite3 通常在 cmd 中对我来说工作得很好
我该如何解决这个问题?
【问题讨论】: