我目前使用的是通过 Visual Studio 2012 中的扩展和更新管理器下载的 SQLite3 v3.7.14。当我为 Win32 编译时它可以工作,但是当我在 ARM 上编译和运行时它没有。每当我尝试设置 sqlite3_temp_directory 时它就会崩溃。我觉得我正在关注这里的文档 ( http://www.sqlite.org/c3ref/temp_directory.html )。
void init()
{
// Set the temporary directory for sqlite prior to opening the database
LPCWSTR zPath = Windows::Storage::ApplicationData::Current->TemporaryFolder->Path->Data();
char zPathBuf[MAX_PATH + 1];
memset(zPathBuf, 0, sizeof(zPathBuf));
WideCharToMultiByte(CP_UTF8, 0, zPath, -1, zPathBuf, sizeof(zPathBuf), NULL, NULL);
sqlite3_temp_directory = sqlite3_mprintf("%s", zPathBuf); // CRASHES HERE ON WINRT
auto localDataPath = Windows::Storage::ApplicationData::Current->LocalFolder->Path;
std::wstring path(localDataPath->Data());
path += L"\\database.sql";
sqlite3_open16(path.c_str(), &m_DB);
}
我想知道我是否遗漏了什么?我不确定如何调试这个,也找不到任何在 WinRT 上使用 SQLite3 或正确使用 sqlite3_temp_directory 的好例子。
更新:
事实证明,如果我绕过官方预编译的 .lib/.dll 文件包含原始 sqlite3.h/.c 文件,上述代码将按预期工作。
最佳答案
SQLite3 团队通知我确实有问题。问题本身要么在 SQLite3 代码库中,要么在 Microsoft MSVC 编译器中,他们正在积极努力寻找解决方案。
事实证明,问题仅在启用优化时出现,主要原因是/Og 开关。您可以暂时禁用构建优化来解决此问题。
关于c++ - Windows RT ARM 平台上的 SQLite3 崩溃,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12559528/