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

时间:2013-07-15 09:10:27

标签: 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并给出了路径..

1 个答案:

答案 0 :(得分:3)

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

这意味着sqlite3.lib正在使用一种C标准库,而您的项目正在使用另一种。您的项目和使用的库必须与Debug / Release选项以及标准库选择的静态/动态使用相匹配。