未定义 C++ sqlite3 api (Visual Studio 2015)

标签 c++ sqlite

所以我想乱搞一下,只是为了学习和东西,但现在我收到一个错误,“sqlite3_api”未定义。

#include "stdafx.h"
#include "sqlite3.h"
#include "sqlite3ext.h"

using namespace std;

#define DB "dumpshit.s3db"

bool isOpenDB = false;
sqlite3 *db;

bool ConnectDB();

bool ConnectDB()
{
    if (sqlite3_open(DB, &db) == SQLITE_OK)
    {
        isOpenDB = true;
        return true;
    }

    return false;
}

这就是现在测试文件中的所有内容。我还将 sqlite3.c 添加到我的源文件中,并将 sqlite3.h + sqlite3ext.h 添加到我的头文件中。

为什么我会收到该错误消息?

最佳答案

无需包含 sqlite3ext.h 文件。 只需要在 Source File 文件夹中包含 sqlite3.h 文件并添加 sqlite3.c 文件并编译程序,程序就会执行,不会出现任何错误。

这是我编写的示例代码并且它正在运行:

#include <sqlite3.h>
#include <stdio.h>

int main(void) 
{
sqlite3 *db;    
sqlite3_stmt *res;
int rec;
/* Opening Database. */
int rec = sqlite3_open("test.db", &db);
/* Preparing the query */    
sqlite3_prepare_v2(db, "create table tb1 (col1 text, col2 text, col3 int)", -1, &res, 0);
 /* Evaluating the statement. */
sqlite3_step(res);    
/* Closing Database. */
sqlite3_close(db);

return 0;
}

希望有帮助..!!

关于未定义 C++ sqlite3 api (Visual Studio 2015),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35850071/

相关文章:

c++ - 需要释放 QList 内容?

C++:大类的性能影响(有很多代码)

c++ - 使用 __m256d 寄存器

Android:SQLite 中的自定义排序规则

android - 在上传到 android 中的 playstore 之前管理数据库

android - SQLite数据库:- Activity unable to start activity info

c++ - 初始化 char* 与 int*

c++ - 删除现有对象时出现段错误

SQLite 全文虚拟表正常可用吗?

sqlite - android - 如何在sqlite中保存加密文本时转义'字符