c++ - 如何使用 C++ 读取 sqlite 数据。?

标签 c++ sqlite

我想使用 C++ 和 VS2010 读取 sqlite 数据库文件,我正在编写下面的代码。

sqlite3 *db;
int rc = sqlite3_open("test.db", &db);

我遇到了这种错误

lib(MSVCR100.dll) : error LNK2005: _strncmp already defined in LIBCMTD.lib(strncmp.obj)
1>MSVCRT.lib(MSVCR100.dll) : error LNK2005: _malloc already defined in LIBCMTD.lib(dbgmalloc.obj)
1>MSVCRT.lib(MSVCR100.dll) : error LNK2005: _free already defined in LIBCMTD.lib(dbgfree.obj)
1>MSVCRT.lib(MSVCR100.dll) : error LNK2005: _realloc already defined in LIBCMTD.lib(dbgrealloc.obj)
1>MSVCRT.lib(MSVCR100.dll) : error LNK2005: _memmove already defined in LIBCMTD.lib(memmove.obj)
1>MSVCRT.lib(MSVCR100.dll) : error LNK2005: _atoi already defined in LIBCMTD.lib(atox.obj)
1>MSVCRT.lib(ti_inst.obj) : error LNK2005: "private: __thiscall type_info::type_info(class type_info const &)" (??0type_info@@AAE@ABV0@@Z) already defined in LIBCMTD.lib(typinfo.obj)
1>MSVCRT.lib(ti_inst.obj) : error LNK2005: "private: class type_info & __thiscall type_info::operator=(class type_info const &)" (??4type_info@@AAEAAV0@ABV0@@Z) already defined in LIBCMTD.lib(typinfo.obj)
1>LINK : warning LNK4098: defaultlib 'MSVCRT' conflicts with use of other libs; use /NODEFAULTLIB:library
1>output\win32\Debug\SC.exe : fatal error LNK1169: one or more multiply defined symbols found

我确实在项目中包含了 sqlite3.lib 并给出了路径..

最佳答案

在您的项目中,您尝试同时使用 C 标准库的 DEBUG 版本和 RELEASE(非 DEBUG)版本。

这意味着 sqlite3.lib 使用的是一种 C 标准库,而您的项目使用的是另一种。您的项目和使用的库必须与调试/发布选项以及标准库的静态/动态使用选项相匹配。

关于c++ - 如何使用 C++ 读取 sqlite 数据。?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17650533/

相关文章:

android - 在圆周上添加 Sprite

Android sqlite - 选择字段为空或为空的记录

python - 在 Peewee 中获取或创建

python - 使用python从sqlite db读取unicode

c++ - 如何避免让我的 GameManager 类与大多数东西成为 friend ?

python & c-c++ 单元程序导致段

c++ - 编译后的静态可执行文件返回 "no such file or directory"

c++ - 为什么贪婪的方法在这种情况下不起作用?

c++ - 如何在 Qt 中使用 SQLite

javascript - 为网站创建实时数据库(或排行榜)