Sqlite sqlite3_config 报错 21

在使用Sqlite3_config()设置多线程模式时遇到21号错误码,解决方法是先调用sqlite3_shutdown(),再依次调用sqlite3_config()和sqlite3_initialize()。同时,确保所有查询都使用同一连接,以实现对数据库连接的序列化。此问题在iOS 5上表现为误用错误。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

要使用Sqlite进行开发,需要用sqlite3_config()函数设置多线程模式,结果发现调用此函数一直ERROR,错误码是21.查看了相关的错误码文档,不明所以。。。之后果断google,找到了问题的所在和解决方案:

I struggled long and hard with this as well and finally got the solution.

sqlite3_config() needs to be called before sqlite3_initialize(). However, the OS might initialize sqlite for us so I also do a sqlite3_shutdown() before the sqlite3_config() i.e. 1) sqlite3_shutdown() 2) sqlite3_config() 3) sqlite3_initialize().

Then its also necessary to use the same connection for every query as it is the access to the database connection that gets serialized. As described herehttp://www.sqlite.org/capi3ref.html#sqliteconfigserialized

So I create a connection as soon as the app starts up and the pass that connection to every class that needs it.

地址:http://stackoverflow.com/questions/7795973/setting-sqlite-config-sqlite-config-serialized-returns-sqlite-misuse-on-ios-5

目前遇到问题:编译方法cmake .. -G "MinGW Makefiles" \ -DCMAKE_INSTALL_PREFIX=../projInstall \ -DENABLE_CURL=OFF \ -DBUILD_TESTING=OFF \ -DENABLE_TIFF=OFF \ -DBUILD_APPS=OFF \ -DBUILD_SHARED_LIBS=OFF \ -DENABLE_INTERNAL_SQLITE=ON编译后检查文件$ nm "D:/shareU-W/windows/lib/proj-9.6.1/projInstall/lib/libproj.a" | grep sqlite300000000000048b0 T proj_context_set_sqlite3_vfs_name U _ZN5osgeo4proj15SQLiteStatementC1EP12sqlite3_stmt U sqlite3_bind_blob U sqlite3_bind_int64 U sqlite3_bind_null U sqlite3_bind_text U sqlite3_close U sqlite3_column_blob U sqlite3_column_bytes U sqlite3_column_int64 U sqlite3_column_text U sqlite3_errmsg U sqlite3_exec U sqlite3_finalize U sqlite3_free_table U sqlite3_get_table U sqlite3_last_insert_rowid U sqlite3_open_v2 U sqlite3_prepare_v2 U sqlite3_reset U sqlite3_step U sqlite3_vsnprintfsqlite3_utils.cpp.obj:0000000000000000 p .pdata$_ZN5osgeo4proj17pj_sqlite3_memvfsD0Ev0000000000000000 p .pdata$_ZN5osgeo4proj17pj_sqlite3_memvfsD1Ev0000000000000000 r .rdata$_ZTIN5osgeo4proj14pj_sqlite3_vfsE0000000000000000 r .rdata$_ZTIN5osgeo4proj17pj_sqlite3_memvfsE0000000000000000 r .rdata$_ZTSN5osgeo4proj14pj_sqlite3_vfsE0000000000000000 r .rdata$_ZTSN5osgeo4proj17pj_sqlite3_memvfsE0000000000000000 r .rdata$_ZTVN5osgeo4proj14pj_sqlite3_vfsE0000000000000000 r .rdata$_ZTVN5osgeo4proj17pj_sqlite3_memvfsE0000000000000000 t .text$_ZN5osgeo4proj17pj_sqlite3_memvfsD0Ev0000000000000000 t .text$_ZN5osgeo4proj17pj_sqlite3_memvfsD1Ev0000000000000000 r .xdata$_ZN5osgeo4proj17pj_sqlite3_memvfsD0Ev0000000000000000 r .xdata$_ZN5osgeo4proj17pj_sqlite3_memvfsD1Ev0000000000000370 T _ZN5osgeo4proj10SQLite
06-28
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值